fix(nodeenv): detect musl regardless of the host triplet vendor - #413
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #290.
Problem
is_x86_64_musl()comparedsysconfig.get_config_var('HOST_GNU_TYPE')to the literalx86_64-pc-linux-musl. That vendor field is not fixed - it is whatever the person who built CPython passed to./configure. Alpine builds its ownpython3package with--build=x86_64-alpine-linux-musl, so the check returnedFalseon every Alpine release I tried:HOST_GNU_TYPEalpine:3.14x86_64-alpine-linux-muslalpine:3.19x86_64-alpine-linux-muslalpine:3.22x86_64-alpine-linux-muslalpine:edgex86_64-alpine-linux-muslpython:3.13-alpinex86_64-pc-linux-muslWith 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 tounofficial-builds.nodejs.org(main). nodeenv reports a successful install and the resultingnodefails withnot found, because the glibc build needs/lib64/ld-linux-x86-64.so.2.The official
python:*-alpineimages build CPython from source and get the defaultpcvendor, which is why CI never caught this - only the distro's ownapk add python3is affected, and that is exactly what a minimal Alpine container running pre-commit uses.Fix
Match the arch and the
-linux-muslsuffix, ignore the vendor field.or ''keeps the call safe whereHOST_GNU_TYPEis 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.22with the distro python3,--platform linux/amd64: install succeeds andbin/node --versionprintsv22.14.0. Before the change the same run died on the missingld-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.pyclean,pytest -m 'not integration' testsgreen.