Repository navigation
Installer: make UV_OVERRIDE space-safe on Apple Silicon (#6503) - #6639
Conversation
On Apple Silicon, install.sh exports UV_OVERRIDE pointing at the bundled overrides-darwin-arm64.txt. uv splits UV_OVERRIDE on whitespace, so a repo cloned under a path containing a space (e.g. /Users/me/Open Source/unsloth) truncates the value and every later uv call aborts with 'error: File not found: <truncated>' (the PyTorch install step in #6503). Copy the overrides file into a space-free temp dir and point uv at the copy when the path contains a space, mirroring the macOS/Linux handling already merged for the Python installer in #6534. The temp dir is removed in the exit trap, and the code falls back to the original path when no space-free temp dir is available, so the no-space and non-macOS paths are unchanged. Adds tests/sh/test_install_uv_override_space.sh, which extracts and runs the install.sh hardening block and checks the spaced, no-space, and spaced-TMPDIR fallback cases.
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
There was a problem hiding this comment.
Code Review
This pull request introduces a workaround in install.sh to handle repository paths containing spaces, which previously caused uv to truncate the UV_OVERRIDE environment variable and fail. It copies the overrides file to a temporary space-free directory and cleans it up on exit. A new test suite test_install_uv_override_space.sh has been added to verify this behavior. The review feedback suggests improving the robustness of the whitespace check by using *[[:space:]]* instead of a literal space, updating the corresponding test assertions, and using a more portable [$] bracket expression in awk to avoid issues across different awk implementations.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| case "$_OVERRIDES_FILE" in | ||
| *" "*) | ||
| _UV_OVERRIDE_TMPDIR=$(mktemp -d 2>/dev/null) || _UV_OVERRIDE_TMPDIR="" | ||
| case "$_UV_OVERRIDE_TMPDIR" in | ||
| "") ;; | ||
| *" "*) rm -rf "$_UV_OVERRIDE_TMPDIR" 2>/dev/null || true; _UV_OVERRIDE_TMPDIR="" ;; |
There was a problem hiding this comment.
Since uv splits the UV_OVERRIDE environment variable on any whitespace (including tabs, newlines, etc.), checking only for literal spaces (*" "*) might miss other whitespace characters that could cause the same truncation issue. Using the POSIX-compliant character class *[[:space:]]* is more robust and covers all whitespace characters.
| case "$_OVERRIDES_FILE" in | |
| *" "*) | |
| _UV_OVERRIDE_TMPDIR=$(mktemp -d 2>/dev/null) || _UV_OVERRIDE_TMPDIR="" | |
| case "$_UV_OVERRIDE_TMPDIR" in | |
| "") ;; | |
| *" "*) rm -rf "$_UV_OVERRIDE_TMPDIR" 2>/dev/null || true; _UV_OVERRIDE_TMPDIR="" ;; | |
| case "$_OVERRIDES_FILE" in | |
| *[[:space:]]*) | |
| _UV_OVERRIDE_TMPDIR=$(mktemp -d 2>/dev/null) || _UV_OVERRIDE_TMPDIR="" | |
| case "$_UV_OVERRIDE_TMPDIR" in | |
| "") ;; | |
| *[[:space:]]*) rm -rf "$_UV_OVERRIDE_TMPDIR" 2>/dev/null || true; _UV_OVERRIDE_TMPDIR="" ;; |
| BLOCK=$(awk ' | ||
| /case "\$_OVERRIDES_FILE" in/ { grab = 1 } | ||
| grab { print } | ||
| grab && /export UV_OVERRIDE="\$_OVERRIDES_FILE"/ { exit } | ||
| ' "$INSTALL_SH") |
There was a problem hiding this comment.
In POSIX awk, escaping $ as \$ inside a regular expression literal /.../ is not standard and can trigger warnings or behave inconsistently across different awk implementations (such as BSD awk on macOS vs GNU awk on Linux). Using a bracket expression [$] is a fully portable way to match a literal $.
| BLOCK=$(awk ' | |
| /case "\$_OVERRIDES_FILE" in/ { grab = 1 } | |
| grab { print } | |
| grab && /export UV_OVERRIDE="\$_OVERRIDES_FILE"/ { exit } | |
| ' "$INSTALL_SH") | |
| BLOCK=$(awk ' | |
| /case "[$]_OVERRIDES_FILE" in/ { grab = 1 } | |
| grab { print } | |
| grab && /export UV_OVERRIDE="[$]_OVERRIDES_FILE"/ { exit } | |
| ' "$INSTALL_SH") |
| case "$UV_OVERRIDE" in | ||
| *" "*) bad "spaced path: UV_OVERRIDE still contains a space ($UV_OVERRIDE)" ;; | ||
| *) ok "spaced path: UV_OVERRIDE is space-free" ;; | ||
| esac |
There was a problem hiding this comment.
To align with the more robust whitespace check using *[[:space:]]*, update the test assertion to verify that UV_OVERRIDE is completely free of any whitespace characters.
| case "$UV_OVERRIDE" in | |
| *" "*) bad "spaced path: UV_OVERRIDE still contains a space ($UV_OVERRIDE)" ;; | |
| *) ok "spaced path: UV_OVERRIDE is space-free" ;; | |
| esac | |
| case "$UV_OVERRIDE" in | |
| *[[:space:]]*) bad "spaced path: UV_OVERRIDE still contains whitespace ($UV_OVERRIDE)" ;; | |
| *) ok "spaced path: UV_OVERRIDE is whitespace-free" ;; | |
| esac |
|
@codex review |
…ling uv splits UV_OVERRIDE on any whitespace, so use the POSIX class *[[:space:]]* rather than a literal space in install.sh (catches tabs and newlines in the path too) and the matching test assertions. Use the portable awk bracket expression [$] instead of \$ in the extraction so the test runs the same under BSD awk (macOS) and GNU awk (Linux). Adds a tab-in-path case.
|
Addressed the review feedback in f8bf649:
Verified the full shell-installer suite still passes under both bash and dash (11/11 assertions), and |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0b8b145dce
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if [ "$_status" -ne 0 ]; then | ||
| _restore_studio_venv_replacement | ||
| fi | ||
| [ -n "${_UV_OVERRIDE_TMPDIR:-}" ] && rm -rf "$_UV_OVERRIDE_TMPDIR" 2>/dev/null || true |
There was a problem hiding this comment.
Initialize UV override temp variable before cleanup
When the caller's environment already contains _UV_OVERRIDE_TMPDIR (for example from a wrapper or an exported shell variable), this trap runs on every exit path, including Linux or no-space installs where this script never created a temp directory, and will rm -rf that inherited path. Initialize the variable to empty before registering the trap, or track a separate created flag, so cleanup only removes directories created by this installer.
Useful? React with 👍 / 👎.
The exit trap rm -rf's _UV_OVERRIDE_TMPDIR. Initialize it to empty before registering the trap so an inherited environment value can never be removed; only a temp dir this script creates (Apple Silicon, spaced path) is cleaned. Adds a structural test asserting the init precedes the trap.
|
Good catch. Fixed in fbb5a9f: |
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fbb5a9f35f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| sh "$TESTS_DIR/sh/test_strixhalo_wsl_reroute.sh" | ||
| sh "$TESTS_DIR/sh/test_uninstall_shared_icon.sh" | ||
| sh "$TESTS_DIR/sh/test_torch_flavor.sh" | ||
| sh "$TESTS_DIR/sh/test_install_uv_override_space.sh" |
There was a problem hiding this comment.
Add the new regression to the CI shell-test list
Adding this only to tests/run_all.sh does not make PR CI execute it: the Shell installer tests job enumerates a fixed script list in .github/workflows/studio-backend-ci.yml:222-232 and does not call tests/run_all.sh. In that CI context, the Apple Silicon spaced-path regression can break again without the new test catching it, despite the test existing locally.
Useful? React with 👍 / 👎.
The Shell installer tests job uses a fixed script list (not tests/run_all.sh), so the new shell test would not run on PRs. Add a pytest wrapper under tests/python/ that invokes it; the auto-discovered repo CPU test job collects tests/python/ and so executes the Apple Silicon spaced-path regression.
|
Fixed in 46db439. The dedicated shell-installer job does use a fixed list, so I added |
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
Fixes the remaining half of #6503:
./install.sh --local(and the piped installer) fail at the PyTorch step when the repo is cloned under a path containing a space, on Apple Silicon:#6534 fixed the
-c/-r/UV_OVERRIDEtruncation on the Python installer side (install_python_stack.py,mlx_repair.py). This PR closes the shell-installer side that was deferred.Root cause
On Apple Silicon,
install.shexportsUV_OVERRIDEso mlx-vlm / mlx-lm's transformers pin is honored:uv splits
UV_OVERRIDEon whitespace, so when the repo lives under.../Open Source/unsloth, the exported value truncates at the first space and every subsequent uv call (including the clean PyTorch command, which itself contains no spaced path) aborts witherror: File not found: .../Open.This is why the reported command looks clean under
set -xand why it only reproduces on macOS arm64: the contaminating value comes from the environment, not the command line, and the export is gated onmacos+arm64.Fix
When
_OVERRIDES_FILEcontains a space, copy it into a space-free temp dir and pointUV_OVERRIDEat the copy (the POSIX approach already used by_uv_safe_pathfor the Python installer in #6534). The temp dir is removed in the existing exit trap (_on_install_exit). It falls back to the original path if no space-free temp dir is available, and the no-space and non-macOS paths are byte-for-byte unchanged.Validation
Reproduced and verified on a real
macos-14runner with uv 0.10.9 (the version from the report) and uv 0.11.24 (latest), all run from the same space-free cwd to rule out a cwd effect:.../Open Source/...)Adds
tests/sh/test_install_uv_override_space.sh, which extracts and runs the actualinstall.shhardening block and asserts the spaced path is copied to a space-free location with identical contents, the no-space path passes through unchanged, a spacedTMPDIRfalls back without leaking a temp dir, a tab in the path is handled like a space, and_UV_OVERRIDE_TMPDIRis cleared before the exit trap. Registered intests/run_all.sh, and run on PRs viatests/python/test_install_uv_override_space.py, which the auto-discovered repo CPU test job collects (the dedicated shell-installer job uses a fixed script list). The full shell-installer suite passes locally under both bash and dash.