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

nvm errors out with exit status 3 in aws code build #3122

Open
NiteshBagle123 opened this issue Jun 2, 2023 · 11 comments
Open

nvm errors out with exit status 3 in aws code build #3122

NiteshBagle123 opened this issue Jun 2, 2023 · 11 comments
Labels
needs followup We need some info or action from whoever filed this issue/PR.

Comments

@NiteshBagle123
Copy link

NiteshBagle123 commented Jun 2, 2023

Error message -
[Container] 2023/06/02 12:24:31 Command did not exit successfully . "$NVM_DIR/nvm.sh" && nvm use 14.17.0 exit status 3

We have aws pipeline with nodejs runtime in it.
We have done below -

  1. Installed nvm and all required node version within pipeline and copied the same in S3 bucket (reason for copy as we are getting 5xx error from nvm, caching mechanism to not install again for every build in cicd pipeline). Script below -
version: 0.2
env:
  shell: bash
phases:
  install:
    runtime-versions:
      nodejs: 14
    commands:
      - /usr/local/bin/aws --version
  pre_build:
    commands:
      - bash ./sh-files/retry.sh 3 "curl -o install.sh --write-out "%{http_code}" https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh"
      - export NVM_DIR="$HOME/.nvm"
      - '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"'
      - '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"'
      - . "$NVM_DIR/nvm.sh" && bash ./sh-files/retry.sh 3 "nvm install 12.22.2"
      - . "$NVM_DIR/nvm.sh" && bash ./sh-files/retry.sh 3 "nvm install 14.17.0"
      - . "$NVM_DIR/nvm.sh" && bash ./sh-files/retry.sh 3 "nvm install 10"
      - . "$NVM_DIR/nvm.sh" && bash ./sh-files/retry.sh 3 "nvm install 14.17.6"
      - aws s3 cp $HOME/.nvm s3://<bucket_name>/cicd-pipeline-nb/dependencies/.nvm --region us-west-2 --recursive
      - echo successfully copied dependencies code

It works fine in aws code build. But when runs other script to copy the S3 .nvm folder in aws code build(other pipeline) instance causes exist 3 issue. Refer script below -

  version: 0.2
  env:
    shell: bash
  phases:
    install:
      on-failure: ABORT
      runtime-versions:
        nodejs: 12
      commands:
        - aws s3 cp s3://<bucket_name>/cicd-pipeline-nb/customer-customization/ . --region us-west-2 --recursive
        - aws s3 cp s3://<bucket_name>/cicd-pipeline-nb/dependencies/.nvm $HOME/.nvm --region us-west-2 --recursive
        - echo ENABLE_SCANS Value $ENABLE_SCANS
        - export NVM_DIR="$HOME/.nvm"
        - '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"'
        - '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"'
        - . "$NVM_DIR/nvm.sh" && nvm use 14.17.0
        - export NODE_OPTIONS="--max-old-space-size=8192"
        - node --version
        - echo Installing yarn...
@NiteshBagle123
Copy link
Author

NiteshBagle123 commented Jun 2, 2023

Script in pipeline 1 (where we download all nvm, node and copy in aws s3 bucket) -

version: 0.2
env:
  shell: bash
phases:
  install:
    runtime-versions:
      nodejs: 14
    commands:
      - /usr/local/bin/aws --version
  pre_build:
    commands:
      - bash ./sh-files/retry.sh 3 "curl -o install.sh --write-out "%{http_code}" https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh"
      - export NVM_DIR="$HOME/.nvm"
      - '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"'
      - '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"'
      - . "$NVM_DIR/nvm.sh" && bash ./sh-files/retry.sh 3 "nvm install 12.22.2"
      - . "$NVM_DIR/nvm.sh" && bash ./sh-files/retry.sh 3 "nvm install 14.17.0"
      - . "$NVM_DIR/nvm.sh" && bash ./sh-files/retry.sh 3 "nvm install 10"
      - . "$NVM_DIR/nvm.sh" && bash ./sh-files/retry.sh 3 "nvm install 14.17.6"
      - aws s3 cp $HOME/.nvm s3://<bucket_name>/cicd-pipeline-nb/dependencies/.nvm --region us-west-2 --recursive
      - echo successfully copied dependencies code

@NiteshBagle123
Copy link
Author

NiteshBagle123 commented Jun 2, 2023

Script which copies S3 .nvm folder in root folder of aws code build and then does nvm use of specific node version (pipeline 2) -

  version: 0.2
  env:
    shell: bash
  phases:
    install:
      on-failure: ABORT
      runtime-versions:
        nodejs: 12
      commands:
        - aws s3 cp s3://<bucket_name>/cicd-pipeline-nb/customer-customization/ . --region us-west-2 --recursive
        - aws s3 cp s3://<bucket_name>/cicd-pipeline-nb/dependencies/.nvm $HOME/.nvm --region us-west-2 --recursive
        - echo ENABLE_SCANS Value $ENABLE_SCANS
        - export NVM_DIR="$HOME/.nvm"
        - '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"'
        - '[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"'
        - . "$NVM_DIR/nvm.sh" && nvm use 14.17.0
        - export NODE_OPTIONS="--max-old-space-size=8192"
        - node --version
        - echo Installing yarn...

@ljharb
Copy link
Member

ljharb commented Jun 2, 2023

Note that the scripts were REALLY unclear with single backticks; i edited it to triple backticks so newlines render properly.

@ljharb
Copy link
Member

ljharb commented Jun 2, 2023

Where exactly does the failure happen? What's the failure output?

@ljharb ljharb added the needs followup We need some info or action from whoever filed this issue/PR. label Jun 2, 2023
@NiteshBagle123
Copy link
Author

@ljharb Failure happing in aws code build in cicd pipeline. Above pasted shell scripts needed install third party dependencies but same working in one code build but when copied in the same in other aws code build it is throwing exit 3 error. Please assist

@NiteshBagle123
Copy link
Author

@ljharb Failure output mentioned below -
Error message -
[Container] 2023/06/02 12:24:31 Command did not exit successfully . "$NVM_DIR/nvm.sh" && nvm use 14.17.0 exit status 3

@ljharb
Copy link
Member

ljharb commented Jun 5, 2023

is it the sourcing that exits 3, or the nvm use?

@NiteshBagle123
Copy link
Author

@ljharb issue when downloading node using nvm.

@ljharb
Copy link
Member

ljharb commented Jun 5, 2023

that command doesn't download node. it sources nvm.sh, and then uses an already-installed version.

@NiteshBagle123
Copy link
Author

@ljharb Please assist why exit status 3 error?

@ljharb
Copy link
Member

ljharb commented Jun 5, 2023

I have no idea. You told me that . "$NVM_DIR/nvm.sh" && nvm use 14.17.0 exited 3. I'm asking if it's the . "$NVM_DIR/nvm.sh" or the nvm use 14.17.0 that exited with 3.

Perhaps you're setting the -e shell option? That's inadvisable if so - try disabling it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs followup We need some info or action from whoever filed this issue/PR.
Projects
None yet
Development

No branches or pull requests

2 participants