fix(install): quote PYTHON_PATH and UV_CMD for paths with spaces on macOS (#10009)

Cherry-picked from PR #10019 by @PStarH.

On macOS, uv stores Python in ~/Library/Application Support/uv/...
which contains a space. Unquoted $PYTHON_PATH and $UV_CMD caused
word-splitting under set -e, silently aborting install.sh.

Quotes all variable expansions in check_python():
- "$PYTHON_PATH" in command invocations
- "$UV_CMD" in uv calls
- Outer quotes on $(...) assignments

Closes #10009
This commit is contained in:
PStarH 2026-04-20 04:58:59 -07:00 committed by Teknium
parent ed76185c15
commit 00192d51f1
2 changed files with 8 additions and 8 deletions

View file

@ -297,7 +297,7 @@ check_python() {
if command -v python >/dev/null 2>&1; then if command -v python >/dev/null 2>&1; then
PYTHON_PATH="$(command -v python)" PYTHON_PATH="$(command -v python)"
if "$PYTHON_PATH" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 11) else 1)' 2>/dev/null; then if "$PYTHON_PATH" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 11) else 1)' 2>/dev/null; then
PYTHON_FOUND_VERSION=$($PYTHON_PATH --version 2>/dev/null) PYTHON_FOUND_VERSION="$("$PYTHON_PATH" --version 2>/dev/null)"
log_success "Python found: $PYTHON_FOUND_VERSION" log_success "Python found: $PYTHON_FOUND_VERSION"
return 0 return 0
fi fi
@ -306,7 +306,7 @@ check_python() {
log_info "Installing Python via pkg..." log_info "Installing Python via pkg..."
pkg install -y python >/dev/null pkg install -y python >/dev/null
PYTHON_PATH="$(command -v python)" PYTHON_PATH="$(command -v python)"
PYTHON_FOUND_VERSION=$($PYTHON_PATH --version 2>/dev/null) PYTHON_FOUND_VERSION="$("$PYTHON_PATH" --version 2>/dev/null)"
log_success "Python installed: $PYTHON_FOUND_VERSION" log_success "Python installed: $PYTHON_FOUND_VERSION"
return 0 return 0
fi fi
@ -315,18 +315,17 @@ check_python() {
# Let uv handle Python — it can download and manage Python versions # Let uv handle Python — it can download and manage Python versions
# First check if a suitable Python is already available # First check if a suitable Python is already available
if $UV_CMD python find "$PYTHON_VERSION" &> /dev/null; then if PYTHON_PATH="$("$UV_CMD" python find "$PYTHON_VERSION" 2>/dev/null)"; then
PYTHON_PATH=$($UV_CMD python find "$PYTHON_VERSION") PYTHON_FOUND_VERSION="$("$PYTHON_PATH" --version 2>/dev/null)"
PYTHON_FOUND_VERSION=$($PYTHON_PATH --version 2>/dev/null)
log_success "Python found: $PYTHON_FOUND_VERSION" log_success "Python found: $PYTHON_FOUND_VERSION"
return 0 return 0
fi fi
# Python not found — use uv to install it (no sudo needed!) # Python not found — use uv to install it (no sudo needed!)
log_info "Python $PYTHON_VERSION not found, installing via uv..." log_info "Python $PYTHON_VERSION not found, installing via uv..."
if $UV_CMD python install "$PYTHON_VERSION"; then if "$UV_CMD" python install "$PYTHON_VERSION"; then
PYTHON_PATH=$($UV_CMD python find "$PYTHON_VERSION") PYTHON_PATH="$("$UV_CMD" python find "$PYTHON_VERSION")"
PYTHON_FOUND_VERSION=$($PYTHON_PATH --version 2>/dev/null) PYTHON_FOUND_VERSION="$("$PYTHON_PATH" --version 2>/dev/null)"
log_success "Python installed: $PYTHON_FOUND_VERSION" log_success "Python installed: $PYTHON_FOUND_VERSION"
else else
log_error "Failed to install Python $PYTHON_VERSION" log_error "Failed to install Python $PYTHON_VERSION"

View file

@ -175,6 +175,7 @@ AUTHOR_MAP = {
"1506751656@qq.com": "hqhq1025", "1506751656@qq.com": "hqhq1025",
"364939526@qq.com": "luyao618", "364939526@qq.com": "luyao618",
"hgk324@gmail.com": "houziershi", "hgk324@gmail.com": "houziershi",
"176644217+PStarH@users.noreply.github.com": "PStarH",
"906014227@qq.com": "bingo906", "906014227@qq.com": "bingo906",
"aaronwong1999@icloud.com": "AaronWong1999", "aaronwong1999@icloud.com": "AaronWong1999",
"agents@kylefrench.dev": "DeployFaith", "agents@kylefrench.dev": "DeployFaith",