nvm icon indicating copy to clipboard operation
nvm copied to clipboard

Unable to install arm64 version of nodejs on alpine

Open malice00 opened this issue 7 months ago • 2 comments

Operating system and version:

nvm debug output:

nvm --version: v0.40.3
$SHELL: 
$SHLVL: 1
whoami: 'root'
${HOME}: /root
${NVM_DIR}: '${HOME}/.nvm'
${PATH}: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
$PREFIX: ''
${NPM_CONFIG_PREFIX}: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
/bin/sh: --version: not found
shell version: ''
uname -a: 'Linux 6.8.0-50-generic #51-Ubuntu SMP PREEMPT_DYNAMIC Sat Nov 9 18:03:35 UTC 2024 x86_64 Linux'
checksum binary: 'sha256sum'
OS version: Welcome to Alpine Linux 3.22
awk: warning: option -W is ignored
BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.

Usage: awk [OPTIONS] [AWK_PROGRAM] [FILE]...

	-v VAR=VAL	Set variable
	-F SEP		Use SEP as field separator
	-f/-E FILE	Read program from FILE
	-e AWK_PROGRAM
awk: /usr/bin/awk, 
curl: /usr/bin/curl, curl 8.14.1 (x86_64-alpine-linux-musl) libcurl/8.14.1 OpenSSL/3.5.0 zlib/1.3.1 brotli/1.1.0 zstd/1.5.7 c-ares/1.34.5 libidn2/2.3.7 libpsl/0.21.5 nghttp2/1.65.0
wget: unrecognized option: V
BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.

Usage: wget [-cqS] [--spider] [-O FILE] [-o LOGFILE] [--header STR]
	[--post-data STR | --post-file FILE] [-Y on/off]
	[-P DIR] [-U AGENT] [-T SEC] URL...

Retrieve files via HTTP or FTP

	--spider	Only check URL existence: $? is 0 if exists
	--header STR	Add STR (of form 'header: value') to headers
	--post-data STR	Send STR using POST method
	--post-file FILE	Send FILE using POST method
	-c		Continue retrieval of aborted transfer
	-q		Quiet
	-P DIR		Save to DIR (default .)
	-S    		Show server response
	-T SEC		Network read timeout is SEC seconds
	-O FILE		Save to FILE ('-' for stdout)
	-o LOGFILE	Log messages to FILE
	-U STR		Use STR for User-Agent header
	-Y on/off	Use proxy
wget: /usr/bin/wget, 
git: not found
grep: /bin/grep, BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.
sed: /bin/sed, BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.
cut: /usr/bin/cut, BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.
basename: /usr/bin/basename, BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.
rm: /bin/rm, BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.
mkdir: /bin/mkdir, BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.
xargs: /usr/bin/xargs, BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.
nvm current: none
which node: 
which iojs: 
which npm: 
npm config get prefix: /bin/sh: npm: not found
npm root -g: /bin/sh: npm: not found

nvm ls output:

ls: unrecognized option: q
BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.

Usage: ls [-1AaCxdLHRFplinshrSXvctu] [-w WIDTH] [FILE]...

List directory contents

	-1	One column output
	-a	Include names starting with .
	-A	Like -a, but exclude . and ..
	-x	List by lines
	-d	List directory names, not contents
	-L	Follow symlinks
	-H	Follow symlinks on command line
	-R	Recurse
	-p	Append / to directory names
	-F	Append indicator (one of */=@|) to names
	-l	Long format
	-i	List inode numbers
	-n	List numeric UIDs and GIDs instead of names
	-s	List allocated blocks
	-lc	List ctime
	-lu	List atime
	--full-time	List full date/time
	-h	Human readable sizes (1K 243M 2G)
	--group-directories-first
	-S	Sort by size
	-X	Sort by extension
	-v	Sort by version
	-t	Sort by mtime
	-tc	Sort by ctime
	-tu	Sort by atime
	-r	Reverse sort order
	-w N	Format N columns wide
	--color[={always,never,auto}]
ls: unrecognized option: q
BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.

Usage: ls [-1AaCxdLHRFplinshrSXvctu] [-w WIDTH] [FILE]...

List directory contents

	-1	One column output
	-a	Include names starting with .
	-A	Like -a, but exclude . and ..
	-x	List by lines
	-d	List directory names, not contents
	-L	Follow symlinks
	-H	Follow symlinks on command line
	-R	Recurse
	-p	Append / to directory names
	-F	Append indicator (one of */=@|) to names
	-l	Long format
	-i	List inode numbers
	-n	List numeric UIDs and GIDs instead of names
	-s	List allocated blocks
	-lc	List ctime
	-lu	List atime
	--full-time	List full date/time
	-h	Human readable sizes (1K 243M 2G)
	--group-directories-first
	-S	Sort by size
	-X	Sort by extension
	-v	Sort by version
	-t	Sort by mtime
	-tc	Sort by ctime
	-tu	Sort by atime
	-r	Reverse sort order
	-w N	Format N columns wide
	--color[={always,never,auto}]
            N/A *
ls: unrecognized option: q
ls: unrecognized option: q
BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.

Usage: ls [-1AaCxdLHRFplinshrSXvctu] [-w WIDTH] [FILE]...

List directory contents

	-1	One column output
	-a	Include names starting with .
	-A	Like -a, but exclude . and ..
	-x	List by lines
	-d	List directory names, not contents
	-L	Follow symlinks
	-H	Follow symlinks on command line
	-R	Recurse
	-p	Append / to directory names
	-F	Append indicator (one of */=@|) to names
	-l	Long format
	-i	List inode numbers
	-n	List numeric UIDs and GIDs instead of names
	-s	List allocated blocks
	-lc	List ctime
	-lu	List atime
	--full-time	List full date/time
	-h	Human readable sizes (1K 243M 2G)
	--group-directories-first
	-S	Sort by size
	-X	Sort by extension
	-v	Sort by version
	-t	Sort by mtime
	-tc	Sort by ctime
	-tu	Sort by atime
	-r	Reverse sort order
	-w N	Format N columns wide
	--color[={always,never,auto}]
BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.

Usage: ls [-1AaCxdLHRFplinshrSXvctu] [-w WIDTH] [FILE]...

List directory contents

	-1	One column output
	-a	Include names starting with .
	-A	Like -a, but exclude . and ..
	-x	List by lines
	-d	List directory names, not contents
	-L	Follow symlinks
	-H	Follow symlinks on command line
	-R	Recurse
	-p	Append / to directory names
	-F	Append indicator (one of */=@|) to names
	-l	Long format
	-i	List inode numbers
	-n	List numeric UIDs and GIDs instead of names
	-s	List allocated blocks
	-lc	List ctime
	-lu	List atime
	--full-time	List full date/time
	-h	Human readable sizes (1K 243M 2G)
	--group-directories-first
	-S	Sort by size
	-X	Sort by extension
	-v	Sort by version
	-t	Sort by mtime
	-tc	Sort by ctime
	-tu	Sort by atime
	-r	Reverse sort order
	-w N	Format N columns wide
	--color[={always,never,auto}]
ls: unrecognized option: q
BusyBox v1.37.0 (2025-05-26 20:04:45 UTC) multi-call binary.

Usage: ls [-1AaCxdLHRFplinshrSXvctu] [-w WIDTH] [FILE]...

List directory contents

	-1	One column output
	-a	Include names starting with .
	-A	Like -a, but exclude . and ..
	-x	List by lines
	-d	List directory names, not contents
	-L	Follow symlinks
	-H	Follow symlinks on command line
	-R	Recurse
	-p	Append / to directory names
	-F	Append indicator (one of */=@|) to names
	-l	Long format
	-i	List inode numbers
	-n	List numeric UIDs and GIDs instead of names
	-s	List allocated blocks
	-lc	List ctime
	-lu	List atime
	--full-time	List full date/time
	-h	Human readable sizes (1K 243M 2G)
	--group-directories-first
	-S	Sort by size
	-X	Sort by extension
	-v	Sort by version
	-t	Sort by mtime
	-tc	Sort by ctime
	-tu	Sort by atime
	-r	Reverse sort order
	-w N	Format N columns wide
	--color[={always,never,auto}]
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)

How did you install nvm?

Using the script from the readme.

What steps did you perform?

I ran an install with an alternate mirror: NVM_NODEJS_ORG_MIRROR=<my internal server> nvm install v24.3.0

What happened?

I got a 404, because nvm is trying to download the x64 version instead of the correct arm64:

Downloading and installing node v24.3.0...
Downloading <my internal server>/v24.3.0/node-v24.3.0-linux-x64-musl.tar.gz...
##O=-#    #                                                                                                                                                                     curl: (22) The requested URL returned error: 404

Nvm then continues to download the source and tries to build it, but ultimately fails with a segmentation fault.

What did you expect to happen?

I had exprected nvm to download and install the arm64 version

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

No

Other

I've checked the sources and it appears that for alpine, the architecture ist always set to 'x64-musl': https://github.com/nvm-sh/nvm/blob/9602f4f959a9f64515fc13af2904a87dc03de685/nvm.sh#L2118-L2120

malice00 avatar Jul 14 '25 23:07 malice00

That was added in ef7fc2f2c / #3212.

In general, I'm happy to change nvm to make things easier for those using unofficial builds, but it's worth noting that nvm is primarily intended for the primary nodejs.org/dist distribution. You'd expect it to download node-v24.3.0-linux-arm64.tar.xz?

What happens if you use the default mirrors?

ljharb avatar Jul 15 '25 19:07 ljharb

I agree that right now, no alpine/musl is 'needed', because it is not officially released by the nodejs team. If in the future they will, the current code would not work for arm64, because of the hard-coded value.

I do not expect it to download node-v24.3.0-linux-arm64.tar.xz, because that version would not work on alpine. Currently it would fall back on building a version from source (which is preferable to downloading an incorrect version which crashes), which would produce the version I am looking for as well. Because this takes quite a long time and/or can run out of resources on smaller computers, I'd prefer the option to build my own version once and host it myself for reuse -- or use the unofficial builds (eg for the actual alpine x85).

This is the exact same behavior I get when using the official mirrors.

Of course, if the detection of the architecture etc becomes to complicated, I also wouldn't mind some parameters/envvars and set them myself.

malice00 avatar Jul 15 '25 20:07 malice00