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

The current version of nvm look for node distribution file which is not present and older version of nvm do find and install node but that does not work #3503

Open
rguptak opened this issue Jan 6, 2025 · 11 comments

Comments

@rguptak
Copy link

rguptak commented Jan 6, 2025

Operating system and version:

Operating System: Alpine Linux v3.21 (containerized)

nvm debug output:

I do not get to the debug

nvm ls output:

How did you install nvm?

What steps did you perform?

Install necessary packages

RUN addgroup -S node && adduser -S node -s /bin/sh -D node && apk update && apk add --no-cache
ca-certificates
curl
bash
wget
git
nmap
openssh
html-xml-utils
jq
python3
python3-dev \
make
openssh-client

Install NVM

RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

Modify PATH to include NVM

ENV PATH="/root/.nvm/versions/node/$(nvm version)bin:$PATH"

Install the latest Node.js version using NVM

RUN source ~/.nvm/nvm.sh &&
nvm install --lts

Set default Node.js version

RUN source ~/.nvm/nvm.sh &&
nvm use --lts

Verify Node.js and npm installation

RUN source ~/.nvm/nvm.sh &&
node -v && npm -v

Set default Node.js version

RUN source ~/.nvm/nvm.sh &&
nvm debug

What happened?

If I use current nvm (v0.40.1) it looks for a file - which is not present see these few lines of output

#9 0.421 Downloading and installing node v22.12.0...
#9 0.518 Downloading https://nodejs.org/dist/v22.12.0/node-v22.12.0-linux-x64-musl.tar.gz...
#=#=# curl: (22) The requested URL returned error: 404
#9 0.692
#9 0.695 download from https://nodejs.org/dist/v22.12.0/node-v22.12.0-linux-x64-musl.tar.gz failed

If I use older nvm (v0.39.3) it download and install the node but the node -v fails and node is not present. See the output

#10 [3/9] RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/...
#10 0.174 % Total % Received % Xferd Average Speed Time Time Time Current
#10 0.174 Dload Upload Total Spent Left Speed
100 15916 100 15916 0 0 257k 0 --:--:-- --:--:-- --:--:-- 259k
#10 0.246 => Downloading nvm from git to '/root/.nvm'
=> Cloning into '/root/.nvm'...
#10 0.911 * (HEAD detached at FETCH_HEAD)
#10 0.911 master
#10 0.913 => Compressing and cleaning up git repository
#10 0.916
#10 0.921 => Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zprofile, ~/.zshrc, and ~/.profile.
#10 0.921 => Create one of them and run this script again
#10 0.921 OR
#10 0.921 => Append the following lines to the correct file yourself:
#10 0.921
#10 0.921 export NVM_DIR="$HOME/.nvm"
#10 0.921 [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
#10 0.921
#10 0.951 => Close and reopen your terminal to start using nvm or run the following to use it now:
#10 0.951
#10 0.951 export NVM_DIR="$HOME/.nvm"
#10 0.951 [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
#10 DONE 1.0s
#9 [4/9] RUN source ~/.nvm/nvm.sh && nvm install --lts
#9 0.205 Installing latest LTS version.
#9 0.398 expr: warning: '^lts/-[1-9][0-9]$': using '^' as the first character
#9 0.398 of a basic regular expression is not portable; it is ignored
#9 0.459 Downloading and installing node v22.12.0...
#9 0.703 Downloading https://nodejs.org/dist/v22.12.0/node-v22.12.0-linux-x64.tar.gz...
######################################################################## 100.0%
#9 1.922 Computing checksum with sha256sum
#9 2.186 Checksums matched!
#9 4.425 Now using node v22.12.0 (npm v)
#9 4.485 Creating default alias: default -> lts/
(-> v22.12.0 *)
#9 DONE 5.0s
#8 [5/9] RUN source ~/.nvm/nvm.sh && nvm use --lts
#8 0.410 Now using node v22.12.0 (npm v)
#8 DONE 0.5s
#7 [6/9] RUN source ~/.nvm/nvm.sh && node -v && npm -v
#7 0.348 /bin/sh: node: not found
#7 ERROR: process "/bin/sh -c source ~/.nvm/nvm.sh && node -v && npm -v" did not complete successfully: exit code: 127

[6/9] RUN source ~/.nvm/nvm.sh && node -v && npm -v:


process "/bin/sh -c source ~/.nvm/nvm.sh && node -v && npm -v" did not complete successfully: exit code: 127

A typical node install using apk add or using n package I end up getting older version 22.11.0 and I need to get 22.12.0

What did you expect to happen?

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

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

@rguptak
Copy link
Author

rguptak commented Jan 6, 2025

I added following command before the install an here is the output

RUN source ~/.nvm/nvm.sh
&& curl -I --compressed -v https://nodejs.org/dist/
&& nvm ls
&& nvm debug \

Output

#8 [3/9] RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/...
#8 0.249 % Total % Received % Xferd Average Speed Time Time Time Current
#8 0.249 Dload Upload Total Spent Left Speed
100 16563 100 16563 0 0 134k 0 --:--:-- --:--:-- --:--:-- 134k
#8 0.389 => Downloading nvm from git to '/root/.nvm'
=> Cloning into '/root/.nvm'...
#8 1.031 * (HEAD detached at FETCH_HEAD)
#8 1.031 master
#8 1.034 => Compressing and cleaning up git repository
#8 1.038
#8 1.044 => Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zprofile, ~/.zshrc, and ~/.profile.
#8 1.044 => Create one of them and run this script again
#8 1.044 OR
#8 1.044 => Append the following lines to the correct file yourself:
#8 1.044
#8 1.044 export NVM_DIR="$HOME/.nvm"
#8 1.044 [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
#8 1.044
#8 1.090 => Close and reopen your terminal to start using nvm or run the following to use it now:
#8 1.090
#8 1.090 export NVM_DIR="$HOME/.nvm"
#8 1.090 [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
#8 DONE 1.2s
#7 [4/9] RUN source ~/.nvm/nvm.sh && curl -I --compressed -v https://no...
#7 0.286 % Total % Received % Xferd Average Speed Time Time Time Current
#7 0.286 Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Host nodejs.org:443 was resolved.
#7 0.311 * IPv6: 2606:4700:10::6814:172e, 2606:4700:10::6814:162e
#7 0.311 * IPv4: 104.20.22.46, 104.20.23.46
#7 0.311 * Trying [2606:4700:10::6814:172e]:443...
#7 0.311 * Immediate connect fail for 2606:4700:10::6814:172e: Network unreachable
#7 0.311 * Trying [2606:4700:10::6814:162e]:443...
#7 0.311 * Immediate connect fail for 2606:4700:10::6814:162e: Network unreachable
#7 0.311 * Trying 104.20.22.46:443...
#7 0.329 * ALPN: curl offers h2,http/1.1
#7 0.330 } [5 bytes data]
#7 0.330 * TLSv1.3 (OUT), TLS handshake, Client hello (1):
#7 0.330 } [512 bytes data]
#7 0.345 * CAfile: /etc/ssl/cert.pem
#7 0.345 * CApath: none
#7 0.359 { [5 bytes data]
#7 0.359 * TLSv1.3 (IN), TLS handshake, Server hello (2):
#7 0.359 { [122 bytes data]
#7 0.360 * TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
#7 0.360 { [19 bytes data]
#7 0.360 * TLSv1.3 (IN), TLS handshake, Certificate (11):
#7 0.360 { [4835 bytes data]
#7 0.361 * TLSv1.3 (IN), TLS handshake, CERT verify (15):
#7 0.361 { [520 bytes data]
#7 0.361 * TLSv1.3 (IN), TLS handshake, Finished (20):
#7 0.361 { [52 bytes data]
#7 0.361 * TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
#7 0.361 } [1 bytes data]
#7 0.361 * TLSv1.3 (OUT), TLS handshake, Finished (20):
#7 0.361 } [52 bytes data]
#7 0.361 * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384 / x25519 / RSASSA-PSS
#7 0.361 * ALPN: server accepted h2
#7 0.361 * Server certificate:
#7 0.362 * subject: CN=*.nodejs.org
#7 0.362 * start date: Feb 28 00:00:00 2024 GMT
#7 0.362 * expire date: Mar 30 23:59:59 2025 GMT
#7 0.362 * subjectAltName: host "nodejs.org" matched cert's "nodejs.org"
#7 0.362 * issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA
#7 0.362 * SSL certificate verify ok.
#7 0.362 * Certificate level 0: Public key type RSA (4096/152 Bits/secBits), signed using sha256WithRSAEncryption
#7 0.362 * Certificate level 1: Public key type RSA (2048/112 Bits/secBits), signed using sha384WithRSAEncryption
#7 0.362 * Certificate level 2: Public key type RSA (4096/152 Bits/secBits), signed using sha384WithRSAEncryption
#7 0.362 * Connected to nodejs.org (104.20.22.46) port 443
#7 0.362 * using HTTP/2
#7 0.362 * [HTTP/2] [1] OPENED stream for https://nodejs.org/dist/
#7 0.362 * [HTTP/2] [1] [:method: HEAD]
#7 0.362 * [HTTP/2] [1] [:scheme: https]
#7 0.362 * [HTTP/2] [1] [:authority: nodejs.org]
#7 0.362 * [HTTP/2] [1] [:path: /dist/]
#7 0.362 * [HTTP/2] [1] [user-agent: curl/8.11.1]
#7 0.362 * [HTTP/2] [1] [accept: /]
#7 0.362 * [HTTP/2] [1] [accept-encoding: deflate, gzip, br, zstd]
#7 0.362 } [5 bytes data]
#7 0.362 > HEAD /dist/ HTTP/2
#7 0.362 > Host: nodejs.org
#7 0.362 > User-Agent: curl/8.11.1
#7 0.362 > Accept: /
#7 0.362 > Accept-Encoding: deflate, gzip, br, zstd
#7 0.362 >
#7 0.362 * Request completely sent off
#7 0.376 { [5 bytes data]
#7 0.376 * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
#7 0.376 { [230 bytes data]
#7 0.376 * TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
#7 0.376 { [230 bytes data]
#7 0.392 < HTTP/2 200
#7 0.392 < date: Mon, 06 Jan 2025 15:24:53 GMT
#7 0.392 < content-type: text/html
#7 0.392 < cache-control: public, max-age=3600, s-maxage=14400
#7 0.392 < last-modified: Mon, 06 Jan 2025 12:35:11 GMT
#7 0.392 < cf-cache-status: HIT
#7 0.392 < age: 9883
#7 0.392 < vary: Accept-Encoding
#7 0.392 < strict-transport-security: max-age=31536000; includeSubDomains; preload
#7 0.393 < x-content-type-options: nosniff
#7 0.393 < server: cloudflare
#7 0.393 < cf-ray: 8fdcb7b44f68bfc0-ATL
#7 0.393 HTTP/2 200
#7 0.393 < content-encoding: br
#7 0.393 <
#7 0.393 { [0 bytes data]
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
#7 0.393 * Connection #0 to host nodejs.org left intact
#7 0.393 date: Mon, 06 Jan 2025 15:24:53 GMT
#7 0.393 content-type: text/html
#7 0.393 cache-control: public, max-age=3600, s-maxage=14400
#7 0.393 last-modified: Mon, 06 Jan 2025 12:35:11 GMT
#7 0.393 cf-cache-status: HIT
#7 0.393 age: 9883
#7 0.393 vary: Accept-Encoding
#7 0.393 strict-transport-security: max-age=31536000; includeSubDomains; preload
#7 0.393 x-content-type-options: nosniff
#7 0.393 server: cloudflare
#7 0.393 cf-ray: 8fdcb7b44f68bfc0-ATL
#7 0.393 content-encoding: br
#7 0.393
#7 0.419 ls: unrecognized option: q
#7 0.424 BusyBox v1.37.0 (2024-11-19 21:09:16 UTC) multi-call binary.
#7 0.424
#7 0.424 Usage: ls [-1AaCxdLHRFplinshrSXvctu] [-w WIDTH] [FILE]...
#7 0.424
#7 0.424 List directory contents
#7 0.424
#7 0.424 -1 One column output
#7 0.424 -a Include names starting with .
#7 0.424 -A Like -a, but exclude . and ..
#7 0.424 -x List by lines
#7 0.424 -d List directory names, not contents
#7 0.424 -L Follow symlinks
#7 0.424 -H Follow symlinks on command line
#7 0.424 -R Recurse
#7 0.424 -p Append / to directory names
#7 0.424 -F Append indicator (one of */=@|) to names
#7 0.424 -l Long format
#7 0.424 -i List inode numbers
#7 0.424 -n List numeric UIDs and GIDs instead of names
#7 0.424 -s List allocated blocks
#7 0.424 -lc List ctime
#7 0.424 -lu List atime
#7 0.424 --full-time List full date/time
#7 0.424 -h Human readable sizes (1K 243M 2G)
#7 0.424 --group-directories-first
#7 0.424 -S Sort by size
#7 0.424 -X Sort by extension
#7 0.424 -v Sort by version
#7 0.424 -t Sort by mtime
#7 0.424 -tc Sort by ctime
#7 0.424 -tu Sort by atime
#7 0.424 -r Reverse sort order
#7 0.424 -w N Format N columns wide
#7 0.424 --color[={always,never,auto}]
#7 0.455 ls: unrecognized option: q
#7 0.460 BusyBox v1.37.0 (2024-11-19 21:09:16 UTC) multi-call binary.
#7 0.460
#7 0.460 Usage: ls [-1AaCxdLHRFplinshrSXvctu] [-w WIDTH] [FILE]...
#7 0.460
#7 0.460 List directory contents
#7 0.460
#7 0.460 -1 One column output
#7 0.460 -a Include names starting with .
#7 0.460 -A Like -a, but exclude . and ..
#7 0.460 -x List by lines
#7 0.460 -d List directory names, not contents
#7 0.460 -L Follow symlinks
#7 0.460 -H Follow symlinks on command line
#7 0.460 -R Recurse
#7 0.460 -p Append / to directory names
#7 0.460 -F Append indicator (one of */=@|) to names
#7 0.460 -l Long format
#7 0.460 -i List inode numbers
#7 0.460 -n List numeric UIDs and GIDs instead of names
#7 0.460 -s List allocated blocks
#7 0.460 -lc List ctime
#7 0.460 -lu List atime
#7 0.460 --full-time List full date/time
#7 0.460 -h Human readable sizes (1K 243M 2G)
#7 0.460 --group-directories-first
#7 0.460 -S Sort by size
#7 0.460 -X Sort by extension
#7 0.460 -v Sort by version
#7 0.460 -t Sort by mtime
#7 0.460 -tc Sort by ctime
#7 0.460 -tu Sort by atime
#7 0.460 -r Reverse sort order
#7 0.460 -w N Format N columns wide
#7 0.460 --color[={always,never,auto}]
#7 0.463 N/A *
#7 0.486 ls: unrecognized option: qls
#7 0.486 : unrecognized option: q
#7 0.491 BusyBox v1.37.0 (2024-11-19 21:09:16 UTC) multi-call binary.
#7 0.491
#7 0.491 Usage: ls [-1AaCxdLHRFplinshrSXvctu] [-w WIDTH] [FILE]...
#7 0.491
#7 0.491 List directory contents
#7 0.491
#7 0.491 -1 One column output
#7 0.491 -a Include names starting with .
#7 0.491 -A Like -a, but exclude . and ..
#7 0.491 -x List by lines
#7 0.491 -d List directory names, not contents
#7 0.491 -L Follow symlinks
#7 0.491 -H Follow symlinks on command line
#7 0.491 -R Recurse
#7 0.491 -p Append / to directory names
#7 0.491 -F Append indicator (one of */=@|) to names
#7 0.491 -l Long format
#7 0.491 -i List inode numbers
#7 0.491 -n List numeric UIDs and GIDs instead of names
#7 0.491 -s List allocated blocks
#7 0.491 -lc List ctime
#7 0.491 -lu List atime
#7 0.491 --full-time List full date/time
#7 0.491 -h Human readable sizes (1K 243M 2G)
#7 0.491 --group-directories-first
#7 0.491 -S Sort by size
#7 0.491 -X Sort by extension
#7 0.491 -v Sort by version
#7 0.491 -t Sort by mtime
#7 0.491 -tc Sort by ctime
#7 0.491 -tu Sort by atime
#7 0.491 -r Reverse sort order
#7 0.491 -w N Format N columns wide
#7 0.491 --color[={always,never,auto}]
#7 0.491 BusyBox v1.37.0 (2024-11-19 21:09:16 UTC) multi-call binary.
#7 0.491
#7 0.491 Usage: ls [-1AaCxdLHRFplinshrSXvctu] [-w WIDTH] [FILE]...
#7 0.491
#7 0.491 List directory contents
#7 0.491
#7 0.491 -1 One column output
#7 0.491 -a Include names starting with .
#7 0.491 -A Like -a, but exclude . and ..
#7 0.491 -x List by lines
#7 0.491 -d List directory names, not contents
#7 0.491 -L Follow symlinks
#7 0.491 -H Follow symlinks on command line
#7 0.491 -R Recurse
#7 0.491 -p Append / to directory names
#7 0.491 -F Append indicator (one of */=@|) to names
#7 0.491 -l Long format
#7 0.491 -i List inode numbers
#7 0.491 -n List numeric UIDs and GIDs instead of names
#7 0.491 -s List allocated blocks
#7 0.491 -lc List ctime
#7 0.491 -lu List atime
#7 0.491 --full-time List full date/time
#7 0.491 -h Human readable sizes (1K 243M 2G)
#7 0.491 --group-directories-first
#7 0.491 -S Sort by size
#7 0.491 -X Sort by extension
#7 0.491 -v Sort by version
#7 0.491 -t Sort by mtime
#7 0.491 -tc Sort by ctime
#7 0.491 -tu Sort by atime
#7 0.491 -r Reverse sort order
#7 0.491 -w N Format N columns wide
#7 0.491 --color[={always,never,auto}]
#7 0.524 ls: unrecognized option: q
#7 0.529 BusyBox v1.37.0 (2024-11-19 21:09:16 UTC) multi-call binary.
#7 0.529
#7 0.529 Usage: ls [-1AaCxdLHRFplinshrSXvctu] [-w WIDTH] [FILE]...
#7 0.529
#7 0.529 List directory contents
#7 0.529
#7 0.529 -1 One column output
#7 0.529 -a Include names starting with .
#7 0.529 -A Like -a, but exclude . and ..
#7 0.529 -x List by lines
#7 0.529 -d List directory names, not contents
#7 0.529 -L Follow symlinks
#7 0.529 -H Follow symlinks on command line
#7 0.529 -R Recurse
#7 0.529 -p Append / to directory names
#7 0.529 -F Append indicator (one of */=@|) to names
#7 0.529 -l Long format
#7 0.529 -i List inode numbers
#7 0.529 -n List numeric UIDs and GIDs instead of names
#7 0.529 -s List allocated blocks
#7 0.529 -lc List ctime
#7 0.529 -lu List atime
#7 0.529 --full-time List full date/time
#7 0.529 -h Human readable sizes (1K 243M 2G)
#7 0.529 --group-directories-first
#7 0.529 -S Sort by size
#7 0.529 -X Sort by extension
#7 0.529 -v Sort by version
#7 0.529 -t Sort by mtime
#7 0.529 -tc Sort by ctime
#7 0.529 -tu Sort by atime
#7 0.529 -r Reverse sort order
#7 0.529 -w N Format N columns wide
#7 0.529 --color[={always,never,auto}]
#7 0.549 iojs -> N/A (default)
#7 0.549 node -> stable (-> N/A) (default)
#7 0.549 unstable -> N/A (default)
#7 ERROR: process "/bin/sh -c source ~/.nvm/nvm.sh && curl -I --compressed -v https://no/dejs.org/dist/ && nvm ls && nvm debug RUN source ~/.nvm/nvm.sh && nvm install --lts" did not complete successfully: exit code: 3

[4/9] RUN source ~/.nvm/nvm.sh && curl -I --compressed -v https://nodejs.org/dist/ && nvm ls && nvm debug RUN source ~/.nvm/nvm.sh && nvm install --lts:


process "/bin/sh -c source ~/.nvm/nvm.sh && curl -I --compressed -v https://nodejs.org/dist/ && nvm ls && nvm debug RUN source ~/.nvm/nvm.sh && nvm install --lts" did not complete successfully: exit code: 3
Running after_script
00:00
Running after script...

@ljharb
Copy link
Member

ljharb commented Jan 6, 2025

Please fill out the issue template; it’s there for a reason.

You shouldn’t be modifying the PATH at all; nvm does that for you.

As for busybox, i believe it’s so is not posix compliant - you may need to install a working one. See also https://github.com/nvm-sh/nvm?tab=readme-ov-file#installing-nvm-on-alpine-linux

@rguptak
Copy link
Author

rguptak commented Jan 6, 2025

Thank you for the prompt response and I changed the script based on the link you provided... and the script looks like this and see the output below. (This has portion of nvm debug output)

Please note that yesterday, in one of the test it downloaded the source and compiled it even after that I was seeing the older nodejs (22.11.0) not the current one (22.12.0).

My goal is to get the 22.12.0 node js. I even tried the npm package n to get the latest and it also get one version older... is there something wrong at the nodejs provider... the default installation also get the one version older...

Script:
RUN addgroup -S node && adduser -S node -s /bin/sh -D node && apk update && apk add --no-cache
nodejs
npm
git
nmap
curl
wget
gawk
openssh
html-xml-utils
jq
python3
python3-dev \
make
bash
ca-certificates
openssl
ncurses
coreutils
gcc
g++
libgcc
linux-headers
grep
util-linux
binutils
findutils
&& apk update
&& apk upgrade

Install NVM

RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash

Set default Node.js version

RUN source ~/.nvm/nvm.sh
&& nvm debug

RUN source ~/.nvm/nvm.sh
&& nvm ls

RUN source ~/.nvm/nvm.sh
&& curl -I --compressed -v https://nodejs.org/dist/

Install the latest Node.js version using NVM

RUN source ~/.nvm/nvm.sh &&
nvm install --lts

Set default Node.js version

RUN source ~/.nvm/nvm.sh &&
nvm use --lts

Verify Node.js and npm installation

RUN source ~/.nvm/nvm.sh &&
node -v && npm -v

Output:

#6 [ 3/11] RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40....
#6 0.222 % Total % Received % Xferd Average Speed Time Time Time Current
#6 0.222 Dload Upload Total Spent Left Speed
100 16563 100 16563 0 0 117k 0 --:--:-- --:--:-- --:--:-- 118k
#6 0.391 => Downloading nvm from git to '/root/.nvm'
=> Cloning into '/root/.nvm'...
#6 1.657 * (HEAD detached at FETCH_HEAD)
#6 1.657 master
#6 1.669 => Compressing and cleaning up git repository
#6 1.679
#6 1.691 => Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zprofile, ~/.zshrc, and ~/.profile.
#6 1.691 => Create one of them and run this script again
#6 1.691 OR
#6 1.691 => Append the following lines to the correct file yourself:
#6 1.691
#6 1.691 export NVM_DIR="$HOME/.nvm"
#6 1.691 [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
#6 1.691
#6 3.345 => Close and reopen your terminal to start using nvm or run the following to use it now:
#6 3.345
#6 3.345 export NVM_DIR="$HOME/.nvm"
#6 3.345 [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
#6 DONE 3.5s
#5 [ 4/11] RUN source ~/.nvm/nvm.sh && nvm debug
#5 0.287 nvm --version: v0.40.1
#5 0.287 $SHELL:
#5 0.287 $SHLVL: 1
#5 0.291 whoami: 'root'
#5 0.291 ${HOME}: /root
#5 0.292 ${NVM_DIR}: '/bin'
#5 0.296 ${PATH}: /usr/local/sbin:/usr/local${NVM_DIR}:/usr/sbin:/usr${NVM_DIR}:/sbin:${NVM_DIR}
#5 0.300 $PREFIX: ''
#5 0.309 ${NPM_CONFIG_PREFIX}: ''
#5 0.309 $NVM_NODEJS_ORG_MIRROR: ''
#5 0.309 $NVM_IOJS_ORG_MIRROR: ''
#5 0.314 /bin/sh: --version: not found
#5 0.317 shell version: ''
#5 0.324 uname -a: 'Linux 6.10.10-1.el8.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Sep 12 13:23:56 EDT 2024 x86_64 GNU/Linux'
#5 0.325 checksum binary: 'sha256sum'
#5 0.335 OS version: Welcome to Alpine Linux 3.21
#5 0.350 awk: /usr/bin/awk, GNU Awk 5.3.1, API 4.0
#5 0.372 curl: /usr/bin/curl, curl 8.11.1 (x86_64-alpine-linux-musl) libcurl/8.11.1 OpenSSL/3.3.2 zlib/1.3.1 brotli/1.1.0 zstd/1.5.6 c-ares/1.34.3 libidn2/2.3.7 libpsl/0.21.5 nghttp2/1.64.0
#5 0.388 wget: /usr/bin/wget, GNU Wget 1.25.0 built on linux-musl.
#5 0.427 git: /usr/bin/git, git version 2.47.1
#5 0.457 grep: /bin/grep, grep (GNU grep) 3.11
#5 0.496 sed: /bin/sed, BusyBox v1.37.0 (2024-12-13 21:18:49 UTC) multi-call binary.
#5 0.532 cut: /usr/bin/cut, cut (GNU coreutils) 9.5
#5 0.561 basename: /usr/bin/basename, basename (GNU coreutils) 9.5
#5 0.592 rm: /bin/rm, rm (GNU coreutils) 9.5
#5 0.627 mkdir: /bin/mkdir, mkdir (GNU coreutils) 9.5
#5 0.672 xargs: /usr/bin/xargs, xargs (GNU findutils) 4.10.0
#5 0.704 nvm current: system
#5 0.714 which node: /usr${NVM_DIR}/node
#5 0.719 which iojs:
#5 0.726 which npm: /usr${NVM_DIR}/npm
#5 1.069 npm config get prefix: /usr/local
#5 1.358 npm root -g: /usr/local/lib/node_modules
#5 ERROR: process "/bin/sh -c source ~/.nvm/nvm.sh && nvm debug" did not complete successfully: exit code: 42

[ 4/11] RUN source ~/.nvm/nvm.sh && nvm debug:


process "/bin/sh -c source ~/.nvm/nvm.sh && nvm debug" did not complete successfully: exit code: 42

@ljharb
Copy link
Member

ljharb commented Jan 6, 2025

So, that the prefix is showing up as /usr/local is a problem - do you have the PREFIX env var set? Note that termux sets this, which means it’s incompatible with npm.

Also, nvm debug is failing correctly; it’s not meant to ever return a zero exit code.

@rguptak
Copy link
Author

rguptak commented Jan 6, 2025

Once again thank you for your kind attention and time...
I'm not setting the PREFIX, In the few lines above you can see it is blank.

#5 0.300 $PREFIX: ''
#5 0.309 ${NPM_CONFIG_PREFIX}: ''

I do use a base image that is built by another group. An it is possible that they may be doing some with it. Is there something I could do to overwrite the value. If so, what value I should set...

And in the next run should I remove nvm debug as this stops the script for me...

@ljharb
Copy link
Member

ljharb commented Jan 6, 2025

It's fine to include nvm debug, but you don't want its return code to abort the process - so maybe nvm debug || echo or something.

Why does it think that $NVM_DIR is /bin? Shouldn't it be $HOME/.nvm?

@rguptak
Copy link
Author

rguptak commented Jan 7, 2025

After I added these in the script it downloaded the source and try to compile but never finished,..

RUN source ~/.nvm/nvm.sh
&& export NVM_DIR="$HOME/.nvm"
&& [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
&& echo 'export NVM_DIR="$HOME/.nvm"' > ~/.bashrc
&& echo '[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"' >> ~/.bashrc
&& cat ~/.bashrc

@ljharb
Copy link
Member

ljharb commented Jan 7, 2025

Compiling node does take a long time.

tbh i'd suggest not using alpine at all; its small size means you have to spend lots of time and disk space doing all the things it's missing.

@rguptak
Copy link
Author

rguptak commented Jan 7, 2025

It seems the nvm would not work for me... would you recommend any other alternate. The default nodejs installation and using npm package n and even apk add all are end up getting one version older which is strange... why would it not get the lts?

@ljharb
Copy link
Member

ljharb commented Jan 7, 2025

I can't help with alternatives to nvm, unfortunately. Is there a reason you are required to use alpine/busybox as your base image?

@rguptak
Copy link
Author

rguptak commented Jan 7, 2025

No worries. Our company policy is to use the (Golden) image they provide as base. It seems nvm is not going to work in this scenario and you can close the ticket.

I'm still curious why the standard install get me a version older and I can't find the answer for it. Since the standard install did not worked that is why I looked into using the nvm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants