uv Install Script: Cross-Platform Rust Binary Deployer

Single-file shell installer for uv 0.11.7 detects arch, downloads platform-specific binaries, handles glibc checks, installs to XDG/~/local paths, auto-adds to PATH via shell profiles, and sets up self-updater with receipts.

Robust Platform Detection and Binary Selection

The script auto-detects the host architecture using uname -m and uname -s, mapping to targets like aarch64-unknown-linux-gnu or x86_64-apple-darwin. It prioritizes glibc-linked binaries only if the system meets minimum versions (e.g., glibc 2.17+ for x86_64-unknown-linux-gnu via check_glibc using ldd --version parsing).

Fallback logic in select_archive_for_arch tries glibc first, then musl static/dynamic variants:

case "$true_arch" in
  "x86_64-unknown-linux-gnu")
    _archive="uv-x86_64-unknown-linux-gnu.tar.gz"
    if ! check_glibc "2" "17"; then _archive=""; fi
    if [ -n "$_archive" ]; then echo "$_archive"; return 0; fi
    _archive="uv-x86_64-unknown-linux-musl.tar.gz"

This ensures compatibility on older distros by preferring static musl builds. Empty json_binary_aliases and aliases_for_binary indicate no symlinks needed, simplifying deployment.

"System glibc version ($_local_glibc) is too old; checking alternatives"

Resilient Download with Checksums and Fallback URLs

Downloads from multiple sources via env vars: UV_DOWNLOAD_URL, INSTALLER_DOWNLOAD_URL, UV_INSTALLER_GHE_BASE_URL, or defaults to https://releases.astral.sh/github/uv/releases/download/0.11.7 and GitHub mirror. Tries URLs sequentially:

for _base_url in $ARTIFACT_DOWNLOAD_URLS; do
  _url="$_base_url/$_artifact_name"
  _dir="$(ensure mktemp -d)"
  _file="$_dir/input$_zip_ext"
  if ! downloader "$_url" "$_file"; then
    say "failed to download $_url" 1>&2
    continue
  fi
  # Verify checksum if provided
  if [ -n "$_checksum_style" ]; then
    verify_checksum "$_file" "$_checksum_style" "$_checksum_value"
  fi
  _download_result=1
  break
done

Supports curl or wget via downloader, with optional updater binary (uv-update). Failures prompt issue reporting: "this may be a standard network error, but it may also indicate that uv's release process is not working."

Unpacks .zip with unzip -q or .tar.* with tar xf --no-same-owner --strip-components 1, avoiding permission issues.

Flexible Installation Layouts and Atomic Moves

Prioritizes locations: UV_INSTALL_DIR override, XDG_BIN_HOME, XDG_DATA_HOME/../bin, ~/.local/bin. Supports layouts: flat (binaries/libs flat), hierarchical (bin/lib split), cargo-home (for Cargo integration).

Uses late-bound expressions (e.g., '$HOME/.local/bin') for receipts and shell snippets, rewriting $HOME for readability via replace_home. Atomic install via temp dirs:

_install_temp=$(mktemp -d "$_install_dir/tmp.XXXXXXXXXX")
for _bin_name in $_bins; do
  ensure mv "$_src_dir/$_bin_name" "$_install_temp"
  ensure chmod +x "$_install_temp/$_bin_name"
done
# Final fast mv to live dir
for _bin_name in $_bins; do
  ensure mv "$_install_temp/$_bin_name" "$_install_dir"
done

Libs/staticlibs go to lib_install_dir. Receipts ($HOME/.local/share/uv/uv-receipt.json) log prefix, layout, modify_path, aliases.

"early-bound: export PATH="/home/myuser/.myapp:$PATH" * late-bound: export PATH="$HOME/.myapp:$PATH""

PATH Integration Across Shells Without Duplicates

Skips if NO_MODIFY_PATH=1 or dir already in $PATH. Creates env script prepending install_dir to PATH. Injects via add_install_dir_to_path into profiles:

  • Primary: .profile (sh-compatible)
  • Shotgun: .profile .bashrc .bash_profile .bash_login
  • Zsh: .zshrc .zshenv
  • Fish: .config/fish/conf.d/uv.fish

Functions like add_install_dir_to_path append only if absent, using grep -q. CI variant (add_install_dir_to_ci_path) for ephemeral envs.

"This code needs to both compute certain paths for itself to write to, and also write them to shell/rc files so that they can look them up"

Updater and Unmanaged Mode

If INSTALL_UPDATER=1 (default, unless UV_DISABLE_UPDATE=1), downloads uv-update, installs alongside uv. UNMANAGED_INSTALL forces no PATH mods/updater. Shellcheck directives ensure POSIX+ compatibility: shellcheck disable=SC2039 for local, aliases local=typeset for ksh/mksh.

Receipt enables uv self update. Verbose/quiet via UV_PRINT_VERBOSE/UV_PRINT_QUIET.

Summarized by x-ai/grok-4.1-fast via openrouter

10561 input / 2426 output tokens in 11292ms

© 2026 Edge