From d0e5a1d61e5cbb6fb426849da7de3cc3dc56f2ce Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Thu, 19 Mar 2026 11:52:32 -0700 Subject: [PATCH] Fix macOS install.sh: stdin consumption and Python discovery (#4472) * Fix macOS install.sh: stdin consumption and Python discovery Two issues when running `curl | sh` on macOS: 1. Commands like `brew install` consume bytes from the piped stdin, causing the shell to lose its place in the script. The remaining source code gets printed as text instead of being executed, so users have to run the installer twice. Fixed by redirecting stdin from /dev/null for brew, apt-get, xcode-select, and the uv installer subprocess. 2. setup.sh searches for Python 3.11-3.13 on the system PATH via `compgen -c`. On macOS systems that only have Python 3.9 and/or 3.14, this fails with "No Python version between 3.11 and 3.13 found" even though uv already installed Python 3.13 into the venv. Fixed by adding the venv's bin/ to PATH before invoking `unsloth studio setup`. * Guard PATH export against empty VENV_ABS_BIN If cd into the venv bin/ fails, VENV_ABS_BIN would be empty and PATH would start with ":", causing the current directory to be searched for executables. Wrap the export in a non-empty check. --- install.sh | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 5e846a2feb..50303ab75a 100755 --- a/install.sh +++ b/install.sh @@ -37,8 +37,8 @@ _smart_apt_install() { _PKGS="$*" # Step 1: Try installing without sudo (works when already root) - apt-get update -y >/dev/null 2>&1 || true - apt-get install -y $_PKGS >/dev/null 2>&1 || true + apt-get update -y /dev/null 2>&1 || true + apt-get install -y $_PKGS /dev/null 2>&1 || true # Step 2: Check which packages are still missing _STILL_MISSING="" @@ -76,8 +76,8 @@ _smart_apt_install() { exit 1 ;; *) - sudo apt-get update -y - sudo apt-get install -y $_STILL_MISSING + sudo apt-get update -y Xcode Command Line Tools are required." echo " Installing (a system dialog will appear)..." - xcode-select --install 2>/dev/null || true + xcode-select --install /dev/null || true echo " After the installation completes, please re-run this script." exit 1 fi @@ -152,7 +152,7 @@ if [ -n "$MISSING" ]; then echo " Install Homebrew from https://brew.sh then re-run this script." exit 1 fi - brew install $MISSING + brew install $MISSING /dev/null 2>&1; then @@ -175,7 +175,7 @@ if ! command -v uv >/dev/null 2>&1; then echo "==> Installing uv package manager..." _uv_tmp=$(mktemp) download "https://astral.sh/uv/install.sh" "$_uv_tmp" - sh "$_uv_tmp" + sh "$_uv_tmp" Installing unsloth (this may take a few minutes)..." uv pip install --python "$VENV_NAME/bin/python" unsloth --torch-backend=auto # ── Run studio setup ── +# Ensure the venv's Python is on PATH for setup.sh's Python discovery. +# On macOS the system Python may be outside the 3.11-3.13 range that +# setup.sh requires, but uv already installed a compatible interpreter +# inside the venv. +VENV_ABS_BIN="$(cd "$VENV_NAME/bin" && pwd)" +if [ -n "$VENV_ABS_BIN" ]; then + export PATH="$VENV_ABS_BIN:$PATH" +fi + echo "==> Running unsloth studio setup..." "$VENV_NAME/bin/unsloth" studio setup