`amplify init` fails when executed inside an existing amplify project
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.
- [X] I have read the guide for submitting 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?
npm
If applicable, what version of Node.js are you using?
14
Amplify CLI Version
9.1.0
What operating system are you using?
macOS/Windows
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
init
Describe the bug
Executing amplify init in a nested directory of a amplify project fails with `.../amplify/cli.json' does not exist
Expected behavior
Nested projects are not supported and the execution should fail fast
Reproduction steps
Test 1
mkdir nested-appcd nested-appamplify initmkdir nested-app-2cd nested-app-2amplify init-> macOS / win : ERROR
Test 2
mkdir nested-appcd nested-appamplify initcd amplifymkdir nested-appcd nested-apppwd -> ~/nested-app/amplify/nested-appamplify init-> macOS / win : ERROR
GraphQL schema(s)
# Put schemas below this line
Project Identifier
No response
Log output
# Put your logs below this line
Additional information
No response
This bug also causes you to not be able to delete apps from the Amplify console either, so you have loaded infrastructure you can't get rid of.
Hi @billygerhard, can you try using the AWS CLI to delete the apps: aws amplify delete-app --app-id <app-di> --region <app-region>
@lazpavel my issue is very strange here. I work at an organisation named Amplify (you can see my github organisation).
I am using my organisation laptop where the default user is Amplify path /Users/Amplify.
i am using aws amplify cli version 9.1.0. I am seeing the following error when i have done amplify init in my flutter project path /Users/Amplify/Varun/workspace/amplify_fb_auth .
Initializing project in the cloud...
CREATE_IN_PROGRESS AuthRole AWS::IAM::Role Thu Jul 14 2022 23:55:21 GMT+0530 (India Standard Time) Resource creation Initiated
⠇ Initializing project in the cloud...
CREATE_COMPLETE UnauthRole AWS::IAM::Role Thu Jul 14 2022 23:55:38 GMT+0530 (India Standard Time)
CREATE_COMPLETE AuthRole AWS::IAM::Role Thu Jul 14 2022 23:55:39 GMT+0530 (India Standard Time)
⠴ Initializing project in the cloud...
CREATE_COMPLETE DeploymentBucket AWS::S3::Bucket Thu Jul 14 2022 23:55:42 GMT+0530 (India Standard Time)
⠧ Initializing project in the cloud...
CREATE_COMPLETE amplify-amplifyfbauth-dev-XXXXXX AWS::CloudFormation::Stack Thu Jul 14 2022 23:55:44 GMT+0530 (India Standard Time)
✔ Successfully created initial AWS cloud resources for deployments.
✔ Help improve Amplify CLI by sharing non sensitive configurations on failures (y/N) · yes
Error: File at path: '/Users/Amplify/Varun/workspace/amplify_fb_auth/amplify/cli.json' does not exist
at Function.readJson (/snapshot/repo/build/node_modules/amplify-cli-core/lib/jsonUtilities.js:40:19)
at StateManager.getData (/snapshot/repo/build/node_modules/amplify-cli-core/lib/state-manager/stateManager.js:309:56)
at StateManager.getCLIJSON (/snapshot/repo/build/node_modules/amplify-cli-core/lib/state-manager/stateManager.js:254:25)
at DebugConfig.getCLIJson (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/app-config/debug-config.js:31:48)
at DebugConfig.writeShareProjectConfig (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/app-config/debug-config.js:44:30)
at DebugConfig.setAndWriteShareProject (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/app-config/debug-config.js:66:14)
at onSuccess (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/init-steps/s9-onSuccess.js:77:45)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/commands/init.js:30:13)
at async Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:292:9)
at async executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:142:5)
at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:40:9)
at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:165:13)
But when i see the cli.json file is getting created at /Users/Amplify/cli.json .
Solution:
What i have done is i have placed the file in required position (/Users/Amplify/Varun/workspace/amplify_fb_auth/amplify/cli.json) and made amplify init with different environment name (ex: learn) which different from the first amplify init (eg: dev)
I request you to revisit your folder and file creation procedure so that we do not have such issue.
Cheers!!!
Hi @vmadupu9, thank you for reporting this, I was able to reproduce the issue
@lazpavel I did try that when it first happened, and it would not delete.
@billygerhard can you paste the output of this command? aws amplify delete-app --app-id <app-di> --region <app-region>
I'm solved it.
When i install the @aws-amplify/cli, my node version was 9.x.
To solve, I run nvm use 16, and reinstall @aws-amplify/cli@latest.