Closed Dickensli closed 5 months ago
Hey @Dickensli, thank you for reaching out. Is the project currently being used in a folder that sync with cloud storage like iCloud or OneDrive? From the reproduction steps this appears to be similar to https://github.com/aws-amplify/amplify-cli/issues/13335
Thanks for the quick turnaround! No, I don't have any backup or sync with external storage. This should be more serious issue than seeing duplicated files. Please see this section
Sometimes, it gets worse, and the api/ folder disappears. When I check Amplify Backend Studio, I see errors like "can't retrieve data since schema is missing." While I can fix this by running amplify push --force, the issue of duplicated files still persists.
Moreover, sometimes what I observed is
function/some_lambda_function
by running amplify add function
amplify push
amplify pull
function/some_lambda_function
and function/some_lambda_function 2
where index.py
and setup.py
were deleted,
and custom-policies.json
, parameter.json
, Pipfile
and Pipfile.lock
were moved from function/some_lambda_function
to function/some_lambda_function 2
Overall, the result appears disorganized ...
Hey @Dickensli, thank you for the information. Could you try the following
#current-cloud-backend.zip
archive, unzip, remove duplicate files, re-zip, and re-upload. While re-zipping do ensure the current-cloud-backend is not being upload as a nested folder. amplify pull --appId <app-id> --envName <env-name>
amplify push
Do let us know if this does still create duplicate files.
On a push Amplify does not make a copy of the directory or files locally, the above enable us to dive deep to the issue. Hi, I deduplicated all files and reupload #current-cloud-backend.zip; running amplify pull --debug --appId dyq20j2b80hyx --envName tuna
I got following error
🛑 Failed to pull the backend.
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
PullBackendFault: Failed to pull the backend.
at attachBackend (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/attach-backend.js:55:15)
at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/commands/pull.js:64:9)
at async Object.executeAmplifyCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/index.js:194:9)
at async executePluginModuleCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:139:5)
at async executeCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:37:9)
at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/index.js:121:5)
File at path: '/Users/dickensli/Desktop/new_amplify/amplify/#current-cloud-backend/amplify-meta.json' does not exist
Error: File at path: '/Users/dickensli/Desktop/new_amplify/amplify/#current-cloud-backend/amplify-meta.json' does not exist
at JSONUtilities.readJson (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-cli-core/lib/jsonUtilities.js:44:19)
at AmplifyToolkit.readJsonFile (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/extensions/amplify-helpers/read-json-file.js:6:45)
at ensureAmplifyMeta (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/attach-backend.js:126:46)
at Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/attach-backend.js:117:36)
at async Object.attachBackend (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/index.js:196:3)
at async queryProvider (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/attach-backend-steps/a10-queryProvider.js:36:5)
at async attachBackend (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/attach-backend.js:43:9)
at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/commands/pull.js:64:9)
at async Object.executeAmplifyCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/index.js:194:9)
at async executePluginModuleCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:139:5)
at async executeCommand (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:37:9)
at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/cli-internal/lib/index.js:121:5)
Session Identifier: 718e26cf-46c3-4064-a22b-6b99d0795434
Hey I finally got it right. The above error is because I accidentally included nested #current-cloud-backend to zip. You are right, my iCloud backup is the root cause. I did not realize iCloud backed up every file on my laptop... but Thanks! Really helpful!
This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.
How did you install the Amplify CLI?
npm
If applicable, what version of Node.js are you using?
v22.4.0
Amplify CLI Version
12.12.4
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 manual changes made
Describe the bug
Every time I run
amplify pull
oramplify push
, duplicate files are generated under the#current-cloud-backend
directory. For example, my backend folder structure looks like this:backend |── api |── awscloudformation/build │ └── root-cloudformation-stack.json |──auth │ └── build |── function |── amplify-meta.json |── backend-config.json |── tags.json
However, the #current-cloud-backend directory ends up with:
current-cloud-backend
|── api |── api 2 |──awscloudformation/build | └── root-cloudformation-stack.json | └── root-cloudformation-stack 2.json |── auth │ └── build │ └── build 2 |── auth 4 |── function |── amplify-meta.json |── amplify-meta 2.json |── backend-config.json |── backend-config 2.json |── tags.json └── tags 2.json
These number-appended folders are usually empty or outdated and vary with each run, e.g. I updated my api's
defaultauthentication
fromAPI_KEY
toAMAZON_COGNITO_USER_POOLS
usingamplify update api
in local; then I ranamplify push
, and twoamplify-meta.json
s were generated.amplify-meta.json
catch the change butamplify-meta 2.json
does not.Sometimes, it gets worse, and the
api/
folder disappears. When I check Amplify Backend Studio, I see errors like "can't retrieve data since schema is missing." While I can fix this by runningamplify push --force
, the issue of duplicated files still persists.One possible cause is: I have turned on CI/CD linked to github repo, usually when I have some backend change, I run
amplify push
, waiting for push to succeed, and then rungit add
,git commit
,git push
which triggers CI/CD runs. Could this introduce any conflict between manual amplify push vs. CI/CD push?my
amplify.yml
Expected behavior
no duplicated files/folders should be generated
Reproduction steps
Project Identifier
083a411c049aa404823988034e0b09f6
Log output
Additional information
No response
Before submitting, please confirm: