Skip to content

Commit ec368f5

Browse files
committed
fix(scripts): handle missing uv gracefully with clear error and auto-install
Add shared ensure_uv() to common.sh that shows install instructions and offers interactive auto-install via install_uv.sh. Remove the no-op override in install_python.sh so the shared function takes effect. Fix SC1091 shellcheck warnings with source directives. Closes #24
1 parent 7b56b04 commit ec368f5

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

scripts/install_python.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
set -euo pipefail
33

44
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
# shellcheck source=scripts/lib/common.sh
56
. "$DIR/lib/common.sh"
7+
# shellcheck source=scripts/lib/install_strategy.sh
68
. "$DIR/lib/install_strategy.sh"
79

810
ACTION="${1:-install}"
911

10-
ensure_uv() { :; }
11-
1212
ensure_python_distro() {
1313
if ! have python3 && have apt-get; then sudo apt-get update && sudo apt-get install -y python3 python3-pip; fi
1414
}

scripts/lib/common.sh

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pipx_uninstall() { have pipx && pipx uninstall "$1" || true; }
3939

4040
# nvm helpers
4141
ensure_nvm_loaded() {
42-
# shellcheck disable=SC1090
42+
# shellcheck disable=SC1090,SC1091
4343
[ -s "$HOME/.nvm/nvm.sh" ] && . "$HOME/.nvm/nvm.sh" || true
4444
}
4545

@@ -82,6 +82,28 @@ prefers_rbenv_ruby() {
8282
is_path_under "$p" "$HOME/.rbenv" || return 1
8383
}
8484

85+
# Ensure uv is available, offer to install if missing
86+
ensure_uv() {
87+
have uv && return 0
88+
log "Error: uv is required but not installed."
89+
log ""
90+
log "Install uv:"
91+
log " curl -LsSf https://astral.sh/uv/install.sh | sh"
92+
log ""
93+
log "Or run: make upgrade-uv"
94+
log ""
95+
log "See: https://docs.astral.sh/uv/"
96+
# Auto-install if interactive and install script exists
97+
local install_script="${DIR:-}/install_uv.sh"
98+
if [ -t 0 ] && [ -f "$install_script" ]; then
99+
read -rp "Install uv now? [Y/n] " answer
100+
case "${answer:-y}" in
101+
[Yy]*|"") bash "$install_script" && have uv && return 0 ;;
102+
esac
103+
fi
104+
return 1
105+
}
106+
85107
# WSL detection
86108
is_wsl() {
87109
grep -qi microsoft /proc/version 2>/dev/null

0 commit comments

Comments
 (0)