aws-amplify / aws-amplify/amplify-cli
"The local environment configuration does not allow modifying the backend." when running `amplify env checkout <env_name>`
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 825
- Avg merge
- 11d 23h
- Merged PRs (30d)
- 2
Description
### Before opening, please confirm:
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-js/issues?q=is%3Aissue+) and [discussions](https://github.com/aws-amplify/amplify-js/discussions).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-js/blob/main/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
### JavaScript Framework
Not applicable
### Amplify APIs
Not applicable
### Amplify Categories
Not applicable
### Environment information
```
System:
OS: macOS 11.7
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Memory: 357.89 MB / 8.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 12.22.12 - ~/.nvm/versions/node/v12.22.12/bin/node
npm: 6.14.17 - ~/.nvm/versions/node/v12.22.12/bin/npm
Browsers:
Chrome: 105.0.5195.125
Safari: 15.5
npmGlobalPackages:
@angular/cli: 14.1.3
@aws-amplify/cli: 9.2.1
memlab: 1.1.27
npm: 6.14.17
pm2: 5.2.0
```
Note: `amplify -v` return 10.0.0.
### Describe the bug
When running `amplify env checkout dev` in an amplify project where there is no backend folder (*), one gets the following error:
> The local environment configuration does not allow modifying the backend.
Use amplify env pull --envName dev
The environment _is_ checked out (as shown by `amplify env list`), but the error above still shows.
Moreover, running `amplify env pull --envName dev` as suggested by the error will yield the following error:
> ✖ There was an error initializing your environment.
⠋ Creating Zip
File at path: '/Users/.../erroramplify2/amplify/backend/backend-config.json' does not exist
✖ Creating Zip
🛑 File at path: '/Users/.../erroramplify2/amplify/backend/backend-config.json' does not exist
(*) Having a project with no backend folder happens when the user responded "No" to "Do you plan on modifying this backend? No" when pulling the project from the cloud with `amplify pull --appId `.
### Expected behavior
The error message should not show, the environment should simply be "checked out"/switched.
### Reproduction steps
1. Initialize a new amplify project: `mkdir amplify-project && cd $_ && amplify init`
2. Select the default configuration.
3. Create a new env: `amplify env add test`
4. Create a new folder to pull the origin amplify project into (say, you're a colleague and want to contribute to the original project): `cd .. && mkdir amplify-project-clone && $_`
5. Pull the amplify project config: `amplify pull --appId
6. Select again default configuration.
7. When asked `Do you plan on modifying this backend?`, respond `No`
8. Run `amplify env checkout test`
9. See the error
### Code Snippet
```javascript
// Put your code below this line.
```
### Log output
```
// Put your logs below this line
```
### aws-exports.js
_No response_
### Manual configuration
_No response_
### Additional configuration
_No response_
### Mobile Device
_No response_
### Mobile Operating System
_No response_
### Mobile Browser
_No response_
### Mobile Browser Version
_No response_
### Additional information and screenshots
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.