nvm-sh / nvm

Node Version Manager - POSIX-compliant bash script to manage multiple active node.js versions
MIT License
79.32k stars 7.94k forks source link

cannot install nvm in Linux failing with `EXIT_CODE=3` #3117

Open v1v opened 1 year ago

v1v commented 1 year ago

Operating system and version:

uname : 'Linux worker-1799330 5.15.0-71-generic #78~20.04.1-Ubuntu SMP Wed Apr 19 11:26:48 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux' OS: "Ubuntu 20.04.5 LTS (Focal Fossa)"

nvm debug output:

N/A

nvm ls output:

N/A

How did you install nvm?

Install script in readme

export NVM_DIR="$HOME/.nvm" && (
  git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"
  cd "$NVM_DIR"
  git checkout `git describe --abbrev=0 --tags --match "v[0-9]*" $(git rev-list --tags --max-count=1)`
) && \. "$NVM_DIR/nvm.sh"

and

curl -sS -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
export NVM_DIR="$HOME/.nvm"
set +x  # Disable xtrace because output using nvm.sh is huge.
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

What steps did you perform?

What happened?

nvm installation failed with the below error:

``` ++++++ NVM_UNAME='Linux worker-1799330 5.15.0-71-generic #78~20.04.1-Ubuntu SMP Wed Apr 19 11:26:48 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux' ++++++ local NVM_OS ++++++ case "${NVM_UNAME}" in ++++++ NVM_OS=linux ++++++ nvm_echo linux ++++++ command printf '%s\n' linux +++++ '[' _linux = _win ']' ++++++ nvm_version_path iojs-v16.20.0 +++++ '[' -x /var/lib/buildkite-agent/.buildkite-agent/builds/workspace/.nvm/versions/io.js/v16.20.0/bin/node ']' +++++ return 1 +++++ '[' '' = true ']' +++++ '[' -z '' ']' +++++ nvm_echo N/A +++++ command printf '%s\n' N/A +++++ return 3 ++++ VERSION=N/A ++++ '[' -z N/A ']' ++++ '[' _N/A = _N/A ']' ++++ nvm_echo N/A ++++ command printf '%s\n' N/A ++++ return 3 +++ VERSION=N/A +++ unset NVM_RC_VERSION +++ '[' -z N/A ']' +++ '[' -z N/A ']' +++ '[' _N/A = _system ']' +++ '[' _N/A = $'_\342\210\236' ']' +++ '[' N/A = N/A ']' +++ '[' 1 -ne 1 ']' +++ return 3 +++ EXIT_CODE=3 +++ set -e +++ return 3 ```

What did you expect to happen?

Either installing it or let me know what's the error about 🙏

Is there anything in any of your profile files that modifies the PATH?

None

If you are having installation issues, or getting "N/A", what does curl -I --compressed -v https://nodejs.org/dist/ print out?

```sh $ curl -I --compressed -v https://nodejs.org/dist/ * Trying 2606:4700:10::6814:162e:443... * TCP_NODELAY set * Connected to nodejs.org (2606:4700:10::6814:162e) port 443 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * successfully set certificate verify locations: * CAfile: /etc/ssl/certs/ca-certificates.crt CApath: /etc/ssl/certs * TLSv1.3 (OUT), TLS handshake, Client hello (1): * TLSv1.3 (IN), TLS handshake, Server hello (2): * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8): * TLSv1.3 (IN), TLS handshake, Certificate (11): * TLSv1.3 (IN), TLS handshake, CERT verify (15): * TLSv1.3 (IN), TLS handshake, Finished (20): * TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1): * TLSv1.3 (OUT), TLS handshake, Finished (20): * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 * ALPN, server accepted to use h2 * Server certificate: * subject: CN=*.nodejs.org * start date: Feb 3 00:00:00 2023 GMT * expire date: Mar 5 23:59:59 2024 GMT * subjectAltName: host "nodejs.org" matched cert's "nodejs.org" * issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA * SSL certificate verify ok. * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0 * Using Stream ID: 1 (easy handle 0x55ca93f40320) > HEAD /dist/ HTTP/2 > Host: nodejs.org > user-agent: curl/7.68.0 > accept: */* > accept-encoding: deflate, gzip, br > * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4): * old SSL session ID is stale, removing * Connection state changed (MAX_CONCURRENT_STREAMS == 256)! < HTTP/2 200 HTTP/2 200 < date: Thu, 25 May 2023 06:42:00 GMT date: Thu, 25 May 2023 06:42:00 GMT < content-type: text/html content-type: text/html < cache-control: public, max-age=14400, s-maxage=14400 cache-control: public, max-age=14400, s-maxage=14400 < last-modified: Thu, 25 May 2023 06:35:04 GMT last-modified: Thu, 25 May 2023 06:35:04 GMT < cf-cache-status: HIT cf-cache-status: HIT < vary: Accept-Encoding vary: Accept-Encoding < strict-transport-security: max-age=31536000; includeSubDomains; preload strict-transport-security: max-age=31536000; includeSubDomains; preload < x-content-type-options: nosniff x-content-type-options: nosniff < server: cloudflare server: cloudflare < cf-ray: 7ccbcbbe299cd97b-HEL cf-ray: 7ccbcbbe299cd97b-HEL < content-encoding: br content-encoding: br < * Connection #0 to host nodejs.org left intact ```
ljharb commented 1 year ago

What happens if you run git clone https://github.com/nvm-sh/nvm.git "$NVM_DIR"?

MananKansara09 commented 1 year ago

I think you have to clone the repo git clone https://github.com/nvm-sh/nvm/ then run install.sh that work for me

v1v commented 1 year ago

I managed to bypass the error when running nvm.sh for the first time in https://github.com/elastic/apm-agent-nodejs/pull/3374/commits/597e18b37c5c91251935f6859dcec57123eee8ff

pretty much

PROFILE=/dev/null bash -c 'curl -sS -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash'
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
if [ -s "$NVM_DIR/nvm.sh" ] ; then
  \. "$NVM_DIR/nvm.sh" || true
fi

It's not what I wanna do, but somehow I could not understand the reason why I could run the same commands in the same machine using an interactive shell, but it failed when running those steps as part of the CI pipeline.

Anyway I'll review whether those questions about cloning https://github.com/nvm-sh/nvm/ work fine in my end.

Thanks 🙏