Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulling environment fails in latest (12.6) CLI version #13313

Closed
2 tasks done
szymondobrzanski opened this issue Oct 6, 2023 · 14 comments
Closed
2 tasks done

Pulling environment fails in latest (12.6) CLI version #13313

szymondobrzanski opened this issue Oct 6, 2023 · 14 comments
Labels
functions Issues tied to the functions category pending-triage Issue is pending triage platform-pull Issues related to `amplify pull`

Comments

@szymondobrzanski
Copy link

How did you install the Amplify CLI?

npm

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

v18.15.0

Amplify CLI Version

12.6

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

After upgrading CLI to version 12.6 pulling environments stopped working.
Zrzut ekranu 2023-10-6 o 11 01 08

Expected behavior

amplify pull works

Reproduction steps

  1. Upgrade CLI to latest version
  2. Run 'amplify pull' command for any environment

Project Identifier

No response

Log output

# Put your logs below this line


Additional information

No response

Before submitting, please confirm:

  • I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
  • I have removed any sensitive information from my code snippets and submission.
@szymondobrzanski szymondobrzanski added the pending-triage Issue is pending triage label Oct 6, 2023
@mkaya95
Copy link

mkaya95 commented Oct 6, 2023

Hi,

I just had the same problem. It seems that there is a problem with the amplify-cli version 12.6.0. Therefore I downgraded version to 12.5.2.

App settings: Environment variables ->
Override _LIVE_UPDATES variable like this;
[{"pkg":"@aws-amplify/cli","type":"npm","version":"12.5.2"}]

@ykethan
Copy link
Member

ykethan commented Oct 6, 2023

Hey @szymondobrzanski @mkaya95 , thank you for reaching. In an empty directory could try using the pull command with the --debug and provide us the output?
Additionally, in the ~/.amplify/logs directory should contain log files with amplify-cli-<Timestamp>.log. Could you rerun the pull command and provide us with any notable error messages observed in the log file or the log outputs?

@ykethan ykethan added pending-response Issue is pending response from the issue author platform-pull Issues related to `amplify pull` labels Oct 6, 2023
@mkaya95
Copy link

mkaya95 commented Oct 9, 2023

@ykethan
When I was pulling/pushing locally I was not receiving any error. However, had a problem with the CI/CD pulling/pushing

2023-10-06T12:21:02.582Z [WARNING]: WARNING: You are using pip version 19.2.3, however version 23.2.1 is available.
                                    You should consider upgrading via the 'pip install --upgrade pip' command.
2023-10-06T12:21:05.156Z [INFO]: �[0mAmplify AppID found: d2***b*pr****. Amplify App name is: CloudFinances-CMS/Backend�[0m
2023-10-06T12:21:05.198Z [INFO]: �[0mBackend environment dev found in Amplify Console app: MYAPPNAME-CMS/Backend�[0m
2023-10-06T12:21:10.962Z [INFO]: 🛑 Failed to pull the backend.
2023-10-06T12:21:10.965Z [INFO]: Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
2023-10-06T12:21:10.974Z [INFO]: 
2023-10-06T12:21:10.974Z [INFO]: Session Identifier: 7824654a-862a-4b96-9014-6ba56eba6ce5
2023-10-06T12:21:10.995Z [ERROR]: !!! Build failed
2023-10-06T12:21:10.995Z [ERROR]: !!! Non-Zero Exit Code detected
2023-10-06T12:21:10.995Z [INFO]: # Starting environment caching...
2023-10-06T12:21:10.996Z [INFO]: # Uploading environment cache artifact...
2023-10-06T12:21:11.047Z [INFO]: # Uploaded environment cache artifact
2023-10-06T12:21:11.047Z [INFO]: # Environment caching completed

@ykethan
Copy link
Member

ykethan commented Oct 10, 2023

Hey @mkaya95, thank you for the information. Tried reproducing the issue but did not observe a similar behaviour.
Could you run amplify diagnose --send-report in your local env and provide us the Project Identifier printed in the output.
Additionally, Could you provide some information on the project, for example is this a mono repo or the amplify.yml file utilized.
This would assist in reproducing the issue.

@szymondobrzanski
Copy link
Author

Hello @ykethan. Issue is happening to me only in project that uses mono repo. For the other 'normal' one, pulling works correctly.
I run amplify pull --debug as you requested. This is console output:

🛑 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:55:17)
    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)

Cannot copy '../uuid/dist/bin/uuid' to a subdirectory of itself, '../uuid/dist/bin/uuid'.
Error: Cannot copy '../uuid/dist/bin/uuid' to a subdirectory of itself, '../uuid/dist/bin/uuid'.
    at onLink (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:146:13)
    at getStats (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:49:45)
    at startCopy (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:38:10)
    at copyDirItem (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:120:10)
    at /snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:113:39
    at Array.forEach (<anonymous>)
    at copyDir (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:113:23)
    at onDir (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:103:10)
    at getStats (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:45:37)
    at startCopy (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:38:10)
    at copyDirItem (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:120:10)
    at /snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:113:39
    at Array.forEach (<anonymous>)
    at copyDir (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:113:23)
    at onDir (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:103:10)
    at getStats (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:45:37)
    at startCopy (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:38:10)
    at copyDirItem (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:120:10)
    at /snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:113:39
    at Array.forEach (<anonymous>)
    at copyDir (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:113:23)
    at onDir (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:103:10)
    at getStats (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:45:37)
    at startCopy (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:38:10)
    at copyDirItem (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:120:10)
    at /snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:113:39
    at Array.forEach (<anonymous>)
    at copyDir (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:113:23)
    at onDir (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:103:10)
    at getStats (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:45:37)
    at startCopy (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:38:10)
    at copyDirItem (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:120:10)
    at /snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:113:39
    at Array.forEach (<anonymous>)
    at copyDir (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:113:23)
    at onDir (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:103:10)
    at getStats (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:45:37)
    at startCopy (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:38:10)
    at copyDirItem (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:120:10)
    at /snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:113:39
    at Array.forEach (<anonymous>)
    at copyDir (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:113:23)
    at onDir (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:103:10)
    at getStats (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:45:37)
    at startCopy (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:38:10)
    at handleFilterAndCopy (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:33:10)
    at Object.copySync (/snapshot/amplify-cli/build/node_modules/fs-extra/lib/copy-sync/copy-sync.js:26:10)
    at downloadBackend (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/attach-backend.js:346:24)
    at async Object.run (/snapshot/amplify-cli/build/node_modules/@aws-amplify/amplify-provider-awscloudformation/lib/attach-backend.js:117:3)
    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:55:17)
    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: 954c7bc0-db70-4360-a118-61ece5bb9b8f

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Oct 11, 2023
@ykethan
Copy link
Member

ykethan commented Oct 12, 2023

@szymondobrzanski thank you for the information. From the error message it appears to be occurring on a uuid package. Is this package part of you lambda function or lambda layer?
Tried to reproduce the issue by creating a mono-repo with lambda layer and function with uuid package, then committed to git, on the hosting build i did not observe any errors on a push or pull.

Could you provide us some additional information amplify.yml script being utilized on Amplify hosting and function/layers configuration(if any)? As this would assist in reproducing the behavior.
Could you run amplify diagnose --send-report in your local env and provide us the Project Identifier printed in the output.

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Oct 12, 2023
@szymondobrzanski
Copy link
Author

Yes, uuid package is used in couple of lambdas, it's used to set id for models object's created by GraphQLClient.
This is amplify.yml we are currently using:

version: 1
backend:
  phases:
    preBuild:
      commands:
        - ln -fs /usr/local/bin/pip3.8 /usr/bin/pip3
        - ln -fs /usr/local/bin/python3.8 /usr/bin/python3
        - pip3 install --user pipenv
        - cd packages/aws_repository/amplify/backend/function/cannabebackendlambdaGQLLayer/lib/
        - npm install
        - cd ../../../../..
        - pwd
        - amplify uninstall -y
        - npm install -g @aws-amplify/[email protected] 
    build:
      commands:
        - amplify version
        - amplifyPush --simple
        - amplify push
        - pwd
        - |
          JSON_FILE="amplify/.config/local-env-info.json"
    
          if [ -f "$JSON_FILE" ]; then
            curr_env=$(grep -oP '"envName": "\K[^"]+' "$JSON_FILE")
            echo "Current environment: $curr_env"
          else
            echo "err: file $JSON_FILE does not exist."
          fi
        - echo ${curr_env}
        - aws s3 cp ./lib/amplifyconfiguration.dart s3://amplify-configuration-files/${curr_env}/amplifyconfiguration.dart
  artifacts:
    baseDirectory: /
    files:
      - '**/*'
  cache:
    paths: []
frontend:
  phases:
    build:
      commands: []
  artifacts:
    baseDirectory: /
    files:
      - '**/*'
  cache:
    paths: []

Project identifier: 14b516f1a9f9856b80b4fbd680c2de74

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Oct 13, 2023
@ykethan
Copy link
Member

ykethan commented Oct 17, 2023

Hey @szymondobrzanski, thank you for your patience. On multiple tries creating a monorepo with functions and layers with uuid packages i have been unable to reprodue the issue. Additionally, tried utilizing the provided amplify.yml in the hosting build to replicate the issue but i was unable to replicate the behaviour.
To dive deeper into the issue, would you be open to sharing your amplify folder at [email protected]?

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Oct 17, 2023
@szymondobrzanski
Copy link
Author

Hey @ykethan, email sent, let me know if you need anything else.

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Oct 19, 2023
@ykethan
Copy link
Member

ykethan commented Oct 20, 2023

Hey @szymondobrzanski, apologies but we did not receive an email, could you check if the email may have failed due to size constraints.

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Oct 20, 2023
@szymondobrzanski
Copy link
Author

It looks like it was sent properly, anyway I sent it from another mailbox.

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Oct 23, 2023
@ykethan
Copy link
Member

ykethan commented Oct 24, 2023

Hey @szymondobrzanski, thank you for the folder. I was able to reproduce the behaviour, the issue appears to be occurring on the cannabebackendlambdaGQLLayer .
For a quick test on removing the following lines in the yml script, the push succeeds.

- cd packages/aws_repository/amplify/backend/function/cannabebackendlambdaGQLLayer/lib/
- npm install
- cd ../../../../..

on diving into the layer, noticed the packages were installed at the root of the lib folder instead of the lib/nodejs folder which comes with the package.json. Could provide us some additional information for installing the packages at lib, is this expected. Could you try installing the packages in the /lib/nodejs and retry the build?

Furthermore, creating a new Amplify backend with the layer and build script then connecting the hosting. Noticed the first build was successful but re-running the same build causes the build fail with the following error creating a symlink

  Cannot copy '../uuid/dist/bin/uuid' to a subdirectory of itself, '../uuid/dist/bin/uuid'.
Error: Cannot copy '../uuid/dist/bin/uuid' to a subdirectory of itself, '../uuid/dist/bin/uuid'.

@ykethan ykethan added pending-response Issue is pending response from the issue author functions Issues tied to the functions category labels Oct 24, 2023
@szymondobrzanski
Copy link
Author

Thank you @ykethan, after I moved package.json to /lib/nodejs pulling started to work fine in latest CLI version.

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Oct 27, 2023
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

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.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
functions Issues tied to the functions category pending-triage Issue is pending triage platform-pull Issues related to `amplify pull`
Projects
None yet
Development

No branches or pull requests

3 participants