on main help sign in
refactor: try to fix install.sh
9caf438robcholz
install.sh+46−1
@@ -38,9 +38,54 @@ require_cmd() {
38 fi
38 fi
39}
39}
40
40
41−require_cmd cargo "Install Rust (cargo) from https://rustup.rs and retry."
42require_cmd git "Install git and retry."
41require_cmd git "Install git and retry."
43
42
43+ensure_cargo() {
44+ if command -v cargo >/dev/null 2>&1; then
45+ return 0
46+ fi
47+
48+ print_message warning "Rust (cargo) is required but not found."
49+ print_message info "You should review and approve the Rust installer before proceeding."
50+ if [[ -t 0 ]]; then
51+ read -r -p "Install Rust using rustup now? (y/N) " reply
52+ case "${reply}" in
53+ y|Y)
54+ if command -v curl >/dev/null 2>&1; then
55+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
56+ elif command -v wget >/dev/null 2>&1; then
57+ wget -qO- https://sh.rustup.rs | sh -s -- -y
58+ else
59+ print_message error "Missing required command: curl or wget"
60+ print_message info "Install Rust manually from https://rustup.rs and retry."
61+ exit 1
62+ fi
63+ # shellcheck source=/dev/null
64+ if [[ -f "$HOME/.cargo/env" ]]; then
65+ # shellcheck disable=SC1090
66+ source "$HOME/.cargo/env"
67+ fi
68+ ;;
69+ *)
70+ print_message info "Install Rust manually from https://rustup.rs and retry."
71+ exit 1
72+ ;;
73+ esac
74+ else
75+ print_message error "Non-interactive shell: cannot prompt to install Rust."
76+ print_message info "Install Rust manually from https://rustup.rs and retry."
77+ exit 1
78+ fi
79+
80+ if ! command -v cargo >/dev/null 2>&1; then
81+ print_message error "Cargo still not available after installation."
82+ print_message info "Open a new shell or run: source \"$HOME/.cargo/env\""
83+ exit 1
84+ fi
85+}
86+
87+ensure_cargo
88+
44CARGO_HOME=${CARGO_HOME:-$HOME/.cargo}
89CARGO_HOME=${CARGO_HOME:-$HOME/.cargo}
45INSTALL_DIR="$CARGO_HOME/bin"
90INSTALL_DIR="$CARGO_HOME/bin"
46
91