asdf-vm / asdf-nodejs

Node.js plugin for asdf version manager
https://github.com/asdf-vm/asdf
MIT License
901 stars 142 forks source link

Proposal: support linux-x64-musl #190

Open dvic opened 3 years ago

dvic commented 3 years ago

It would be nice if we could support the musl build (https://github.com/nodejs/unofficial-builds#builds)

augustobmoura commented 2 years ago

It should work on master right now, at least theoretically, as we are using node-build and it supports building from source. If that doesn't work please let me know and we re-open this issue

phortx commented 2 years ago

Hi, I've tried but I'm not sure how to force asdf install to compile the musl version. Any hints?

augustobmoura commented 2 years ago

Just installing nodejs on a distribution based on musl should work by default. Node.js already detects musl as the libc and make the correct assumptions (alpine Dockerfile for reference).

Cross-compiling from another libc on the other hand should be a bit tricky, I think the best chance is the official building docs for nodejs and the official issue tracker. You can pass building options for both configure and make by using node-build options

augustobmoura commented 2 years ago

Actually, I see the problem, node-build is not detecting that musl dists have different binaries from glibc and is not building from source by default, is just downloading glibc binaries instead. I will try to debug it and fix it upstream

augustobmoura commented 2 years ago

FYI: I just merged #284, which adds an option to force compilation. You can just run ASDF_NODEJS_FORCE_COMPILE=1 asdf install nodejs latest and it will force a compilation.

I tested on an alpine container, and it works. Just be sure to install all nodejs building dependencies. Aside from what is listed on the official docs, I also needed to install the packages openssl and linux-headers when using the latest alpine distribution

I still gonna work on a patch upstream for supporting pre-compiled binaries, the problem was a bit more difficult than I antecipated.

Stratus3D commented 2 years ago

Chiming in to confirm @augustobmoura's instructions worked for me on Alpine 3.11.

danielb2 commented 1 year ago

this ticket has been open quite awhile. is it a difficult fix?

augustobmoura commented 1 year ago

NodeJS doesn't provide official pre-compiled binaries for alpine-musl as of yet. They do have an unofficial branch that have the binaries, but, unfortunately, it still not supported on node-build (the engine we use for installing the versions).

The only way to do it right now is by compiling from source inside the musl container/system as per https://github.com/asdf-vm/asdf-nodejs/issues/190#issuecomment-1034334159

danielb2 commented 1 year ago

instead of installing broken binaries, would it not be better to refuse the install with some kind of message?

augustobmoura commented 1 year ago

instead of installing broken binaries, would it not be better to refuse the install with some kind of message?

As a maintainer with very limited time, I am prioritizing the most recurrent issues. We will get to musl pre-compiled binaries eventually. We are also open to contributions, if you think a warning would help, we would appreciate a new PR