Schniz / fnm

🚀 Fast and simple Node.js version manager, built in Rust
https://fnm.vercel.app
GNU General Public License v3.0
17.42k stars 441 forks source link

FNM_ARCH does **NOT** default to arch of fnm binary #942

Open darkbasic opened 1 year ago

darkbasic commented 1 year ago
niko@talos2 ~ $ whereis fnm
fnm: /usr/bin/fnm

niko@talos2 ~ $ file /usr/bin/fnm
/usr/bin/fnm: ELF 64-bit LSB pie executable, 64-bit PowerPC or cisco 7500, OpenPOWER ELF V2 ABI, version 1 (SYSV), dynamically linked, interpreter /lib64/ld64.so.2, for GNU/Linux 3.10.0, stripped

niko@talos2 ~ $ fnm install --lts
Installing Node v18.15.0 (x64)

niko@talos2 ~ $ whereis node
node: /usr/bin/node /usr/include/node /home/niko/.local/share/fnm/node-versions/v18.15.0/installation/bin/node /usr/share/man/man1/node.1.bz2

niko@talos2 ~ $ file /home/niko/.local/share/fnm/node-versions/v18.15.0/installation/bin/node
/home/niko/.local/share/fnm/node-versions/v18.15.0/installation/bin/node: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=417328b1953d476d486d4bfa7f9a79d6571d694c, with debug_info, not stripped, too many notes (256)

niko@talos2 ~ $ fnm env
export PATH="/run/user/1000/fnm_multishells/5570_1679408817584/bin":$PATH
export FNM_NODE_DIST_MIRROR="https://nodejs.org/dist"
export FNM_ARCH="x64"
export FNM_VERSION_FILE_STRATEGY="local"
export FNM_DIR="/home/niko/.local/share/fnm"
export FNM_MULTISHELL_PATH="/run/user/1000/fnm_multishells/5570_1679408817584"
export FNM_LOGLEVEL="info"

niko@talos2 ~ $ uname -a
Linux talos2 6.2.7-gentoo-dist #1 SMP Fri Mar 17 22:32:24 CET 2023 ppc64le POWER9, altivec supported PowerNV T2P9S01 REV 1.01 GNU/Linux
darkbasic commented 1 year ago

My workaround for the moment is to put the following into .bashrc:

eval "$(fnm env --arch ppc64le --use-on-cd)"
steve-ross commented 1 year ago

Would be nice to detect the node version and then default to the appropriate version ex: node less than 15 use x86 else arch! : )

Schniz commented 1 year ago

@steve-ross it's literally what happens https://github.com/Schniz/fnm/blob/5e075f05d4920b4afe35edec448765d1fa02dc32/src/arch.rs#L19-L22

I don't unerstand what is ppc64le but I guess it can be an easy fix by adding support for it here? https://github.com/Schniz/fnm/blob/5e075f05d4920b4afe35edec448765d1fa02dc32/src/system_info.rs

steve-ross commented 1 year ago

Oh my bad! ppc64le ... old ass Mac?! 🙃

darkbasic commented 1 year ago

I don't unerstand what is ppc64le but I guess it can be an easy fix by adding support for it here?

It's PowerPC 64 bit Little Endian. Yes it should be easy enough and I will file a PR as soon as I will manage to test it.

ppc64le ... old ass Mac?!

Nope, brand new IBM Power 8/9/10 CPUs. In particular I am using the RaptorCS Talos 2, the only modern system available which is 100% open source down to the firmware. Old Macs are Big Endian only.

darkbasic commented 1 year ago

By the way FYI fnm does not build out of the box on ppc64le, because of the ring dependency. I've managed to find an IBM branch of ring which compiles fine, at least if you keep around your .git directory (that last part is weird and I have no idea why it happens).

EDIT: ring 0.17 should support all little endian architectures but it's still unreleased, plus it's not a direct dependency so the packages which depend on it must be updated to use the newer version as well.