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

Doesn't work on Alpine linux (musl) #694

Open
timsofteng opened this issue Mar 10, 2022 · 13 comments
Open

Doesn't work on Alpine linux (musl) #694

timsofteng opened this issue Mar 10, 2022 · 13 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@timsofteng
Copy link

I've installed it as guide described.

>  curl -fsSL https://fnm.vercel.app/install | zsh
 
>  fnm install 16
 
>   ./.fnm/node-versions/v16.14.0/installation/bin/node -v
zsh: no such file or directory: ./.fnm/node-versions/v16.14.0/installation/bin/node
@everyx
Copy link

everyx commented Jul 27, 2022

I found a repo with Alpine(musl) support patch: https://github.com/shyim/fnm-alpine , and can we get Alpine official support?

@Schniz
Copy link
Owner

Schniz commented Aug 16, 2022

we need to add another rust build for that. could be a nice contribution

@Schniz Schniz added enhancement New feature or request good first issue Good for newcomers labels Aug 16, 2022
@arvati
Copy link

arvati commented Apr 29, 2023

I just update fnm alpine version on my repo: https://github.com/vanaware/fnm-alpine
You may install like this:

curl -fsSL https://vanaware.github.io/fnm-alpine/install.sh | ash

No needed to change rust build, basicaly just needed to change node source files to this repo:
"https://unofficial-builds.nodejs.org/download/release/"
and use musl version of node.

Known bugs:

  • not able to install from "latest" keyword you must provide version number like this: fnm install 20

Edit:

  • updated to version 1.35.1

@Vinfall
Copy link
Contributor

Vinfall commented Apr 11, 2024

I'm offering a native solution in #1109, just three lines of code. A test build patched upon a5a497b is available here.

And following commands.md, add these to your shell rc:

export FNM_NODE_DIST_MIRROR=https://unofficial-builds.nodejs.org/download/release
export FNM_ARCH=x64-musl

Reload by exec zsh or whatever, done.

Now you can install like fnm install --lts as usual.

@NamesMT
Copy link

NamesMT commented May 9, 2024

If anyone use Alpine and zsh, you could use my simple install script, which uses @Vinfall build under-the-hood.
It basically downloads Vinfall's build and set all the required exports to zsh: ARCH, DIST_MIRROR, PATH, fnm env --use-on-cd

wget https://raw.githubusercontent.com/NamesMT/images-alpine/main/scripts/install-fnm.sh -O- | sh

btw only required dep is unzip

@Vinfall
Copy link
Contributor

Vinfall commented May 10, 2024

Wow, I think the artifact is already expired but it seems the expiration date is 90 days by default. Since you noticed that, I've uploaded the assets to release with hashes. Maybe you'll find it useful to verify the checksum in the script.

@Vinfall
Copy link
Contributor

Vinfall commented May 25, 2024

Just FYI: #1109 is merged so in next release with v1.36.0 you can use official build and set those shell rc I mentioned in #694 (comment) to use fnm in x64 musl-libc distros.

Edit: a new release is already available and I've removed my fork.

@tindzk
Copy link

tindzk commented Jun 15, 2024

Here is a complete example that works with Alpine 3.17 and the default ash shell:

# Resolves linking errors such as:
# Error loading shared library libstdc++.so.6: No such file or directory (needed by /root/.local/state/fnm_multishells/15_1718461045839/bin/node)
apk add libstdc++6 libstdc++

mkdir bin/
cd bin/
wget https://github.com/Schniz/fnm/releases/download/v1.37.1/fnm-linux.zip
unzip fnm-linux.zip
chmod +x fnm
cd -

export PATH=$(pwd)/bin/:$PATH

eval "$(fnm env)"
export FNM_NODE_DIST_MIRROR=https://unofficial-builds.nodejs.org/download/release
export FNM_ARCH=x64-musl

cd ci/

fnm install
fnm use

npm ci

@fabricionaweb
Copy link

fabricionaweb commented Oct 7, 2024

Is there a way to make the FNM_ARCH to detect and return x64-musl when on Alpine? It currently returns x64

--edit--

Ok I figured, opening the MR.

@Vinfall
Copy link
Contributor

Vinfall commented Oct 8, 2024

Yeah, I'm a bit lazy to only get rid of the hardcoded arch check. After #1271 is merged you no longer need to set FNM_ARCH manually. FNM_NODE_DIST_MIRROR is still needed since musl builds only exist in unofficial mirror.

@Schniz
Copy link
Owner

Schniz commented Oct 8, 2024

unfortunately #1271 can't be merged without supporting the formal nodejs mirror which doesn't have musl builds. we have to have multiple platform support or figure out the lack of glibc in runtime.

@ibrahimqasim
Copy link

I don't know enough to make a suggestion, except that this is still the case for v1.38.1.
My use case is an Alpine 3.20 container where I want to set this up.

@fabricionaweb
Copy link

fabricionaweb commented Jan 21, 2025

I don't know enough to make a suggestion, except that this is still the case for v1.38.1. My use case is an Alpine 3.20 container where I want to set this up.

If your platform is x64 you can use the alpine (not official) testing aport where it builds fnm using the unofficial mirrors.

apk add -X https://dl-cdn.alpinelinux.org/alpine/edge/testing fnm

If you want use the official builds from the github releases, then you need to setup the envs (and install libstdc++)

export FNM_NODE_DIST_MIRROR=https://unofficial-builds.nodejs.org/download/release
export FNM_ARCH=x64-musl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

9 participants