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

Issue with amplify push after adding function #13593

Closed
2 tasks done
sidshrivastav opened this issue Feb 15, 2024 · 10 comments
Closed
2 tasks done

Issue with amplify push after adding function #13593

sidshrivastav opened this issue Feb 15, 2024 · 10 comments
Labels
functions Issues tied to the functions category pending-response Issue is pending response from the issue author pending-triage Issue is pending triage

Comments

@sidshrivastav
Copy link

sidshrivastav commented Feb 15, 2024

How did you install the Amplify CLI?

npm install -g @aws-amplify/cli

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

v20.11.1

Amplify CLI Version

12.10.1

What operating system are you using?

Ubuntu 22.04

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

No manual changes.

Describe the bug

I added a function using amplify add function. Now whenever I try to run amplify push, it was throwing error related to yarn.

Initially I was getting error

🛑 Packaging lambda function failed with the error 
Command failed with exit code 1: yarn --no-bin-links --production

I tried all the possible solution but nothing worked.
After that I updated yarn to version "4.1.0", Now I am getting

🛑 Received error [Error: Command failed with exit code 1: yarn --version] running command [yarn --version]

In function source "npm i" is working, which switch the use of yarn to npm but then I get

🛑 Packaging lambda function failed with the error 
Command failed with exit code 243: npm install --no-bin-links --production

Expected behavior

It should allow me to push successfully

Reproduction steps

  1. amplify add function
  2. amplify push
  3. Initially by default it uses yarn
  4. Go to function and run "npm i"
  5. It switches to npm. [npm is not installed using sudo]
  6. Both npm/yarn throwing error

Project Identifier

1a1531b527bd8301a262c456a8ba59a0

Log output

Yarn Error

2024-02-15T08:01:24.026Z|info : amplify push core  {"debug":true,"yes":false}
2024-02-15T08:01:24.065Z|info : @aws-amplify/amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({}
2024-02-15T08:01:25.689Z|info : amplify-provider-awscloudformation.zip-util.downloadZip.s3.getFile([{"Key":"[***]rent-[***]ud-[***]d.zip"},null])
2024-02-15T08:01:25.691Z|info : amplify-provider-awscloudformation.aws-s3.s3.getFile([{"Key":"[***]rent-[***]ud-[***]d.zip","Bucket":"[***]ify-[***]ernext-[***]ev-[***]56-[***]ment"}])
2024-02-15T08:01:26.112Z|info : amplify-provider-awscloudformation.initialize-env.run.cfn.updateamplifyMetaFileWithStackOutputs([{"StackName":"[***]ify-[***]ernext-[***]ev-[***]56"}])
2024-02-15T08:01:26.118Z|info : amplify-provider-awscloudformation.aws-cfn.updateamplifyMetaFileWithStackOutputs.cfn.listStackResources([{"StackName":"[***]ify-[***]ernext-[***]ev-[***]56"}])
2024-02-15T08:01:26.370Z|info : amplify-provider-awscloudformation.aws-cfn.describeStack.cfn.describeStacks([{"StackName":"[***]ify-[***]ernext-[***]ev-[***]56"}])
2024-02-15T08:01:26.557Z|info : amplify-provider-awscloudformation.aws-cfn.describeStack.cfn.describeStacks([{"StackName":"[***]rmation:ap-[***]th-[***]30:stack/[***]ify-[***]ernext-[***]ev-[***]56-[***]ternext-[***]IYERY8/[***]4040-[***]21-[***]ee-[***]53-[***]eabd8"}])
2024-02-15T08:01:26.559Z|info : amplify-provider-awscloudformation.aws-cfn.describeStack.cfn.describeStacks([{"StackName":"[***]rmation:ap-[***]th-[***]30:stack/[***]ify-[***]ernext-[***]ev-[***]56-[***]extacc08a84-[***]FJYFP/[***]a040-[***]a5-[***]ed-[***]a1-[***]30c0e"}])
2024-02-15T08:01:26.561Z|info : amplify-provider-awscloudformation.aws-cfn.describeStack.cfn.describeStacks([{"StackName":"[***]rmation:ap-[***]th-[***]30:stack/[***]ify-[***]ernext-[***]ev-[***]56-[***]eronext-[***]DHKRHS/[***]d5c0-[***]4a-[***]ed-[***]6b-[***]63924"}])
2024-02-15T08:01:26.740Z|info : amplify-provider-awscloudformation.aws-s3.s3.getFile([{"Key":"[***]ify-[***]json","Bucket":"[***]ify-[***]ernext-[***]ev-[***]56-[***]ment"}])
2024-02-15T08:01:31.192Z|error : Received error [Error: Command failed with exit code 1: yarn --version] running command [yarn --version]
ShellCommandExecutionError: Received error [Error: Command failed with exit code 1: yarn --version] running command [yarn --version]


NPM error

2024-02-15T07:57:30.438Z|info : amplify push core  {"debug":true,"yes":false}
2024-02-15T07:57:30.480Z|info : @aws-amplify/amplify-cli-core.banner-message/index.ts.fetch banner messages from https://aws-amplify.github.io/amplify-cli/banner-message.json({}
2024-02-15T07:57:32.589Z|info : amplify-provider-awscloudformation.zip-util.downloadZip.s3.getFile([{"Key":"[***]rent-[***]ud-[***]d.zip"},null])
2024-02-15T07:57:32.592Z|info : amplify-provider-awscloudformation.aws-s3.s3.getFile([{"Key":"[***]rent-[***]ud-[***]d.zip","Bucket":"[***]ify-[***]ernext-[***]ev-[***]56-[***]ment"}])
2024-02-15T07:57:33.098Z|info : amplify-provider-awscloudformation.initialize-env.run.cfn.updateamplifyMetaFileWithStackOutputs([{"StackName":"[***]ify-[***]ernext-[***]ev-[***]56"}])
2024-02-15T07:57:33.104Z|info : amplify-provider-awscloudformation.aws-cfn.updateamplifyMetaFileWithStackOutputs.cfn.listStackResources([{"StackName":"[***]ify-[***]ernext-[***]ev-[***]56"}])
2024-02-15T07:57:33.337Z|info : amplify-provider-awscloudformation.aws-cfn.describeStack.cfn.describeStacks([{"StackName":"[***]ify-[***]ernext-[***]ev-[***]56"}])
2024-02-15T07:57:33.503Z|info : amplify-provider-awscloudformation.aws-cfn.describeStack.cfn.describeStacks([{"StackName":"[***]rmation:ap-[***]th-[***]30:stack/[***]ify-[***]ernext-[***]ev-[***]56-[***]ternext-[***]IYERY8/[***]4040-[***]21-[***]ee-[***]53-[***]eabd8"}])
2024-02-15T07:57:33.504Z|info : amplify-provider-awscloudformation.aws-cfn.describeStack.cfn.describeStacks([{"StackName":"[***]rmation:ap-[***]th-[***]30:stack/[***]ify-[***]ernext-[***]ev-[***]56-[***]extacc08a84-[***]FJYFP/[***]a040-[***]a5-[***]ed-[***]a1-[***]30c0e"}])
2024-02-15T07:57:33.506Z|info : amplify-provider-awscloudformation.aws-cfn.describeStack.cfn.describeStacks([{"StackName":"[***]rmation:ap-[***]th-[***]30:stack/[***]ify-[***]ernext-[***]ev-[***]56-[***]eronext-[***]DHKRHS/[***]d5c0-[***]4a-[***]ed-[***]6b-[***]63924"}])
2024-02-15T07:57:33.688Z|info : amplify-provider-awscloudformation.aws-s3.s3.getFile([{"Key":"[***]ify-[***]json","Bucket":"[***]ify-[***]ernext-[***]ev-[***]56-[***]ment"}])
2024-02-15T07:57:39.726Z|error : Packaging lambda function failed with the error 
Command failed with exit code 243: npm install --no-bin-links --production
PackagingLambdaFunctionError: Packaging lambda function failed with the error 
Command failed with exit code 243: npm install --no-bin-links --production

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.
@sidshrivastav sidshrivastav added the pending-triage Issue is pending triage label Feb 15, 2024
@ykethan
Copy link
Member

ykethan commented Feb 15, 2024

Hey @sidshrivastav, thank you for reaching. The issue is currently being tracked on #13001 and #13377. Refer to the workarounds posted here: #13001 (comment) and #13377 (comment)

After switching to npm, was the amplify.state modified? could you provide us a snippet of the file.

@ykethan ykethan added functions Issues tied to the functions category pending-response Issue is pending response from the issue author labels Feb 15, 2024
@sidshrivastav
Copy link
Author

After switching to npm, was the amplify.state modified? could you provide us a snippet of the file.

hey @ykethan, sorry I am not sure how to check amplify state, can you help me with that?

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Feb 16, 2024
@sidshrivastav
Copy link
Author

Also with yarn 3, 4 I am getting,
🛑 Received error [Error: Command failed with exit code 1: yarn --version] running command [yarn --version]

and with classic verison:
🛑 Packaging lambda function failed with the error Command failed with exit code 1: yarn --no-bin-links --production

Workaround you shared, I don't think is related to that.

@ykethan
Copy link
Member

ykethan commented Feb 17, 2024

Hey @sidshrivastav, the amplify.state may be hidden on Vscode. Could you open the .vscode/setting.json and set the "amplify/**/amplify.state" as false.
Additionally, refer to comment #13377 (comment) providing information on using yarn 4 with function by modifying the amplify.state.

Additionally, curious on the error message Command failed with exit code 243: npm install --no-bin-links --production. Could you provide us the npm version currently installed.

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Feb 17, 2024
@sidshrivastav
Copy link
Author

Additionally, curious on the error message Command failed with exit code 243: npm install --no-bin-links --production. Could you provide us the npm version currently installed.

npm version is 10.2.4

Initially when "amplify push" ran with yarn by default

Error:
Received error [Error: Command failed with exit code 1: yarn --version] running command [yarn --version]

cd to function src, and ran npm i

Error
Packaging lambda function failed with the error Command failed with exit code 243: npm install --no-bin-links --production

Amplify state remains same.
amplify.state

{
  "pluginId": "amplify-nodejs-function-runtime-provider",
  "functionRuntime": "nodejs",
  "useLegacyBuild": true,
  "defaultEditorFile": "src/index.js"
}

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Feb 17, 2024
@sidshrivastav
Copy link
Author

@ykethan Additionally I ran it on docker container just to test on latest nodejs image, "amplify push" didn't push due to permission but i didn't got these issues.

@ykethan
Copy link
Member

ykethan commented Feb 20, 2024

@sidshrivastav thank you for the information. We can add/modify the scripts in the state to modify the build command.

For example default lambda function:

{
  "pluginId": "amplify-nodejs-function-runtime-provider",
  "functionRuntime": "nodejs",
  "useLegacyBuild": true,
  "defaultEditorFile": "src/index.js",
  "scripts": {
    "build": "npm install --no-bin-links --production"
  }
}

or

{
  "pluginId": "amplify-nodejs-function-runtime-provider",
  "functionRuntime": "nodejs",
  "useLegacyBuild": true,
  "defaultEditorFile": "src/index.js",
  "scripts": {
    "build": "yarn"
  }
}

@ykethan ykethan added the pending-response Issue is pending response from the issue author label Feb 20, 2024
@sidshrivastav
Copy link
Author

Hey, I started using nix environment where amplify is working. I test this modification on scripts and let you know

@github-actions github-actions bot removed the pending-response Issue is pending response from the issue author label Feb 22, 2024
@ykethan ykethan added the pending-response Issue is pending response from the issue author label Feb 22, 2024
@ykethan
Copy link
Member

ykethan commented May 3, 2024

Closing the issue due to inactivity. Do reach out to us if you require any assistance.

@ykethan ykethan closed this as not planned Won't fix, can't repro, duplicate, stale May 3, 2024
Copy link

github-actions bot commented May 3, 2024

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.

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-response Issue is pending response from the issue author pending-triage Issue is pending triage
Projects
None yet
Development

No branches or pull requests

2 participants