aws-amplify / aws-amplify/amplify-cli

inconsistencies between packaged CLI and using a package manager

Open
#10,610 3 comments 0 reactions 0 assignees View on GitHub
bug installation p2
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### Before opening, please confirm:

- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.

### How did you install the Amplify CLI?

pnpm

### If applicable, what version of Node.js are you using?

v16.14.2

### Amplify CLI Version

8.5.0

### What operating system are you using?

mac

### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

no

### Amplify Categories

Not applicable

### Amplify Commands

Not applicable

### Describe the bug

- unable to use package manager to downgrade to previous version of CLI without using the `amplify` binary or package manager to first uninstall
- we used to be able to downgrade by simply installing a different version `pnpm add -g @aws-amplify@8.3.0`
- now we have to run `pnpm rm -g @aws-amplify/cli` or `amplify uninstall` to first remove
- `amplify uninstall` does not remove the binary from the package manager and we are able to run `amplify version` to re-download the previously-installed CLI
- `amplify uninstall` removes entire `~/.amplify` directory but package manager uninstall does not

```
josef ~/D/p/a/r/my-project
> amplify version
8.5.0

josef ~/D/p/a/r/my-project
> amplify uninstall
? Are you sure you want to uninstall the Amplify CLI? Yes
Uninstalled the Amplify CLI

up to date, audited 1 package in 148ms

found 0 vulnerabilities

josef ~/D/p/a/r/my-project
> pnpm list -g
Legend: production dependency, optional only, dev only

/Users/josef/Library/pnpm/global/5

dependencies:
@aws-amplify/cli 8.3.0

josef ~/D/p/a/r/my-project
> amplify version
Downloading release from https://package.cli.amplify.aws/8.3.0/amplify-pkg-macos-x64.tgz
amplify has been installed!
8.3.0
8.3.0

josef ~/D/p/a/r/my-project
> pnpm add -g @aws-amplify/cli@8.3.0
# ...
/Users/josef/Library/pnpm/global/5:
- @aws-amplify/cli 8.5.0
+ @aws-amplify/cli 8.3.0 (8.5.0 is available)

josef ~/D/p/a/r/my-project
> amplify version
8.5.0
```

differences between `amplify uninstall` and `pnpm rm -g @aws-amplify/cli`
```
josef ~/D/p/a/r/my-project
> ls -al ~/.amplify
total 56
-rw-r--r-- 1 josef staff 129B Jun 15 10:56 amplify-configuration.json
drwxr-xr-x 3 josef staff 96B Jun 15 10:57 bin/
drwxr-xr-x 7 josef staff 224B Jun 15 10:57 lib/
drwxr-xr-x 4 josef staff 128B Jun 15 10:56 logs/
-rw-r--r-- 1 josef staff 23K Jun 15 10:57 plugins.json

josef ~/D/p/a/r/my-project
> amplify uninstall
? Are you sure you want to uninstall the Amplify CLI? Yes
Uninstalled the Amplify CLI

up to date, audited 1 package in 174ms

found 0 vulnerabilities

josef ~/D/p/a/r/my-project
> ls -al ~/.amplify
ls: /Users/josef/.amplify: No such file or directory

josef ~/D/p/a/r/my-project
> pnpm rm -g @aws-amplify/cli
# ...
/Users/josef/Library/pnpm/global/5:
- @aws-amplify/cli 8.5.0

josef ~/D/p/a/r/my-project
> ls -al ~/.amplify
total 56
-rw-r--r-- 1 josef staff 129B Jun 15 11:20 amplify-configuration.json
drwxr-xr-x 3 josef staff 96B Jun 15 11:20 bin/
drwxr-xr-x 7 josef staff 224B Jun 15 11:20 lib/
drwxr-xr-x 4 josef staff 128B Jun 15 11:20 logs/
-rw-r--r-- 1 josef staff 23K Jun 15 11:20 plugins.json

josef ~/D/p/a/r/my-project
> pnpm rm -g @aws-amplify/cli
 ERR_PNPM_CANNOT_REMOVE_MISSING_DEPS  Cannot remove '@aws-amplify/cli': no such dependency found in 'dependencies'

josef ~/D/p/a/r/my-project
> ~/.amplify/bin/amplify version
8.5.0
```

### Expected behavior

1. removing the CLI from the package manager should remove supplemental files in user's HOME, OR provide documentation for manually cleaning up
2. removing the CLI with `amplify uninstall` should also remove the entry from the package manager, or disable this command when the package is installed through a package manager and document workflow for first removing the package with the package manager
3. allow managing versions with the chosen package manager

### Reproduction steps

see snippets above

### GraphQL schema(s)

```graphql
# Put schemas below this line

```

### Log output

```
# Put your logs below this line

```

### Additional information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the version and uninstall flows shown with pnpm and the amplify commands, comparing package-manager state with ~/.amplify. Trace the CLI entry points for amplify uninstall and version downloading; done means package-manager installation, downgrade, uninstall, and cleanup behave consistently with the three expected behaviors.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.