Skip to content

Select musllinux wheel tag for uv on musl-based distros#1628

Merged
j178 merged 1 commit intoj178:masterfrom
shaanmajid:fix/musl-uv-wheel-tag
Feb 12, 2026
Merged

Select musllinux wheel tag for uv on musl-based distros#1628
j178 merged 1 commit intoj178:masterfrom
shaanmajid:fix/musl-uv-wheel-tag

Conversation

@shaanmajid
Copy link
Collaborator

@shaanmajid shaanmajid commented Feb 12, 2026

Closes #1623

Summary

On musl-based systems (e.g. Alpine), prek downloaded a glibc-linked binary from PyPI wheels, which failed with dynamic linker errors. Match HOST.environment to select the correct musllinux_1_1_* wheel tag for x86_64, i686, and armv7.

Also validate managed uv binaries before reuse so a previously-cached glibc binary is detected as incompatible and re-downloaded with the correct tag, and fix the install helpers to use targeted file removal instead of remove_dir_all on the parent directory.

Tests

Triggered Build Binaries workflow run 21935753880 to build artifacts-x86_64-unknown-linux-musl

Released prek MRE (fails)

docker run --rm --platform linux/amd64 alpine:3.20 sh -c '
  apk add --no-cache curl git python3 >/dev/null 2>&1
  curl -LsSf https://github.com/j178/prek/releases/download/v0.3.2/prek-x86_64-unknown-linux-musl.tar.gz \
    | tar -xz -C /usr/local/bin --strip-components=1
  mkdir /tmp/repo && cd /tmp/repo && git init -q
  printf "repos:\n  - repo: https://github.com/pre-commit/pre-commit-hooks\n    rev: v5.0.0\n    hooks:\n      - id: trailing-whitespace\n" > .pre-commit-config.yaml
  echo "test " > file.txt && git add .
  PREK_UV_SOURCE=pypi prek run 2>&1; echo "EXIT: $?"
  echo "--- uv link type ---"
  ldd /root/.cache/prek/tools/uv/uv 2>&1 | head -3
'

Downloads glibc-linked uv, crashes:

error: Failed to install hook `trailing-whitespace`
  caused by: Failed to create Python virtual environment
  caused by: Run command `create venv` failed
  caused by: No such file or directory (os error 2)
EXIT: 2
--- uv link type ---
/lib64/ld-linux-x86-64.so.2 (0x...)

PR binary (succeeds)

wnload the artifact from CI, then:

docker run --rm --platform linux/amd64 \
  -v /path/to/prek-x86_64-unknown-linux-musl.tar.gz:/artifact.tar.gz:ro \
  alpine:3.20 sh -c '
  apk add --no-cache git python3 >/dev/null 2>&1
  tar -xzf /artifact.tar.gz -C /usr/local/bin --strip-components=1
  mkdir /tmp/repo && cd /tmp/repo && git init -q
  printf "repos:\n  - repo: https://github.com/pre-commit/pre-commit-hooks\n    rev: v5.0.0\n    hooks:\n      - id: trailing-whitespace\n" > .pre-commit-config.yaml
  echo "test " > file.txt && git add .
  PREK_UV_SOURCE=pypi prek run 2>&1; echo "EXIT: $?"
  echo "--- uv link type ---"
  /root/.cache/prek/tools/uv/uv --version
  ldd /root/.cache/prek/tools/uv/uv 2>&1 | head -3
'

Downloads musl-linked uv, hook runs correctly:

trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook
  Fixing file.txt
EXIT: 1
--- uv link type ---
uv 0.9.27
/lib/ld-musl-x86_64.so.1 (0x...)

Exit code 1 is the hook fixing trailing whitespace, not a failure.

On musl-based systems (e.g. Alpine), prek downloaded a glibc-linked uv
binary from PyPI wheels, which failed with relocation errors. Resolve by
matching HOST.environment to select the correct musllinux wheel platform
tag for x86_64, i686, and armv7.

Validate managed uv before reuse so a previously-cached glibc binary is
detected as unusable and re-downloaded with the correct tag.

Fix the install helpers to not remove_dir_all the target directory
before renaming into it; now that managed uv is validated before reuse,
this path is reachable and would produce ENOENT. Use targeted file
removal that preserves the parent directory and lock file.

Closes j178#1623
@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 78.61635% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.78%. Comparing base (92647ff) to head (abc30ec).

Files with missing lines Patch % Lines
crates/prek/src/languages/python/uv.rs 78.61% 34 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1628      +/-   ##
==========================================
+ Coverage   91.75%   91.78%   +0.03%     
==========================================
  Files          96       96              
  Lines       18795    18915     +120     
==========================================
+ Hits        17245    17361     +116     
- Misses       1550     1554       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shaanmajid shaanmajid added the bug Something isn't working label Feb 12, 2026
@prek-ci-bot
Copy link

prek-ci-bot bot commented Feb 12, 2026

📦 Cargo Bloat Comparison

Binary size change: +0.00% (23.8 MiB → 23.8 MiB)

Expand for cargo-bloat output

Head Branch Results

 File  .text    Size             Crate Name
 0.3%   0.7% 71.3KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6% 66.6KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.3%   0.6% 65.6KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 51.2KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.5% 50.5KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.4% 43.4KiB              prek prek::identify::by_extension::{{closure}}
 0.2%   0.4% 41.2KiB              prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4% 39.0KiB              prek prek::run::{{closure}}
 0.1%   0.3% 32.0KiB             prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 28.5KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2% 25.0KiB             prek? <prek::config::_::<impl serde_core::de::Deserialize for prek::config::Config>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2% 22.8KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2% 22.2KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 21.1KiB      clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 20.4KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 20.0KiB   cargo_metadata? <cargo_metadata::_::<impl serde_core::de::Deserialize for cargo_metadata::Package>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2% 19.8KiB              prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 19.3KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2% 19.2KiB              prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
 0.1%   0.2% 19.0KiB              prek prek::hook::HookBuilder::build::{{closure}}
38.6%  91.6%  9.2MiB                   And 21051 smaller methods. Use -n N to show more.
42.1% 100.0% 10.0MiB                   .text section size, the file size is 23.8MiB

Base Branch Results

 File  .text    Size             Crate Name
 0.3%   0.7% 71.3KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.3%   0.6% 66.4KiB             prek? <prek::cli::Command as clap_builder::derive::Subcommand>::augment_subcommands
 0.3%   0.6% 65.6KiB              prek prek::languages::<impl prek::config::Language>::run::{{closure}}::{{closure}}
 0.2%   0.5% 51.2KiB annotate_snippets annotate_snippets::renderer::render::render
 0.2%   0.5% 50.5KiB              prek prek::languages::<impl prek::config::Language>::install::{{closure}}
 0.2%   0.4% 43.4KiB              prek prek::identify::by_extension::{{closure}}
 0.2%   0.4% 41.2KiB              prek prek::cli::run::run::run::{{closure}}
 0.2%   0.4% 39.0KiB              prek prek::run::{{closure}}
 0.1%   0.3% 32.0KiB             prek? <prek::cli::RunArgs as clap_builder::derive::Args>::augment_args
 0.1%   0.3% 28.5KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2% 25.0KiB             prek? <prek::config::_::<impl serde_core::de::Deserialize for prek::config::Config>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2% 22.8KiB      serde_saphyr saphyr_parser_bw::scanner::Scanner<T>::fetch_more_tokens
 0.1%   0.2% 22.2KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 21.1KiB      clap_builder clap_builder::parser::parser::Parser::get_matches_with
 0.1%   0.2% 20.4KiB              prek prek::hooks::meta_hooks::MetaHooks::run::{{closure}}
 0.1%   0.2% 20.0KiB   cargo_metadata? <cargo_metadata::_::<impl serde_core::de::Deserialize for cargo_metadata::Package>::deserialize::__Visitor as serde_core::de::Visitor>::visit_map
 0.1%   0.2% 19.8KiB              prek prek::archive::unzip::{{closure}}
 0.1%   0.2% 19.3KiB               std core::ptr::drop_in_place<prek::languages::<impl prek::config::Language>::install::{{closure}}>
 0.1%   0.2% 19.2KiB              prek <prek::languages::ruby::ruby::Ruby as prek::languages::LanguageImpl>::install::{{closure}}
 0.1%   0.2% 19.0KiB              prek prek::hook::HookBuilder::build::{{closure}}
38.6%  91.6%  9.2MiB                   And 21033 smaller methods. Use -n N to show more.
42.1% 100.0% 10.0MiB                   .text section size, the file size is 23.8MiB

@shaanmajid shaanmajid force-pushed the fix/musl-uv-wheel-tag branch from abc30ec to 6c2d8a4 Compare February 12, 2026 06:31
@shaanmajid shaanmajid marked this pull request as ready for review February 12, 2026 06:31
@shaanmajid shaanmajid requested a review from j178 as a code owner February 12, 2026 06:31
Copy link
Owner

@j178 j178 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@j178 j178 merged commit 75f198b into j178:master Feb 12, 2026
48 of 49 checks passed
@shaanmajid shaanmajid deleted the fix/musl-uv-wheel-tag branch February 12, 2026 19:49
@shaanmajid
Copy link
Collaborator Author

@j178 I'm not sure if it's just a glitch on my side, but https://github.com/j178/prek/pull/1628/checks?check_run_id=63350830094 shows as still running for me (for over 1d...)? If you see it too, I think you should cancel it... (I don't have permission :p)

@j178
Copy link
Owner

j178 commented Feb 14, 2026

I don’t see any option to cancel that check either. It looks like a glitch on the Codecov.io service :(

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prek tries to run a glibc-based uv binary in a musl-based distro

2 participants