Skip to content

fix(nodeenv): detect musl regardless of the host triplet vendor - #413

Merged
ekalinin merged 1 commit into
masterfrom
fix/musl-vendor-detection
Sep 22, 2026
Merged

ekalinin merged 1 commit into
masterfrom
fix/musl-vendor-detection

Conversation

@ekalinin

Copy link
Copy Markdown
Owner

Closes #290.

Problem

is_x86_64_musl() compared sysconfig.get_config_var('HOST_GNU_TYPE') to the literal x86_64-pc-linux-musl. That vendor field is not fixed - it is whatever the person who built CPython passed to ./configure. Alpine builds its own python3 package with --build=x86_64-alpine-linux-musl, so the check returned False on every Alpine release I tried:

image python HOST_GNU_TYPE
alpine:3.14 3.9.17 x86_64-alpine-linux-musl
alpine:3.19 3.11.14 x86_64-alpine-linux-musl
alpine:3.22 3.12.14 x86_64-alpine-linux-musl
alpine:edge 3.14.7 x86_64-alpine-linux-musl
python:3.13-alpine 3.13.15 x86_64-pc-linux-musl

With detection off, all three of its call sites go the wrong way: the archive postfix (get_node_bin_url), the release filter (_has_platform_build) and the switch to unofficial-builds.nodejs.org (main). nodeenv reports a successful install and the resulting node fails with not found, because the glibc build needs /lib64/ld-linux-x86-64.so.2.

The official python:*-alpine images build CPython from source and get the default pc vendor, which is why CI never caught this - only the distro's own apk add python3 is affected, and that is exactly what a minimal Alpine container running pre-commit uses.

Fix

Match the arch and the -linux-musl suffix, ignore the vendor field. or '' keeps the call safe where HOST_GNU_TYPE is undefined (Windows), which the old == comparison handled implicitly.

test_mirror_option() kept its own two-entry list of triplet spellings - it now reuses the helper instead, so the suite stops duplicating the logic it is testing around.

Verification

  • alpine:3.22 with the distro python3, --platform linux/amd64: install succeeds and bin/node --version prints v22.14.0. Before the change the same run died on the missing ld-linux-x86-64.so.2.
  • debian:12-slim: unchanged, still takes the glibc build from nodejs.org.
  • flake8 --extend-ignore=E127 nodeenv.py tests setup.py clean, pytest -m 'not integration' tests green.

is_x86_64_musl() compared HOST_GNU_TYPE to the literal
x86_64-pc-linux-musl, which only matches a CPython configured with the
default vendor. Alpine builds its own python3 with --build=x86_64-alpine
-linux-musl, so the check returned False on every Alpine from 3.14 to
edge: nodeenv then took the glibc build from nodejs.org and the
installed node died with "not found" on the missing
/lib64/ld-linux-x86-64.so.2.

Match the arch and the -linux-musl suffix instead and ignore the vendor
field. test_mirror_option() now reuses the helper rather than keeping
its own list of triplet spellings.

Closes #290
@ekalinin
ekalinin merged commit b1f0c54 into master Sep 22, 2026
44 checks passed
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

Successfully merging this pull request may close these issues.

Installation broken on alpine 3.14

1 participant