diff --git a/install.sh b/install.sh index f7d4baa19c..d90195399d 100755 --- a/install.sh +++ b/install.sh @@ -718,8 +718,20 @@ _smart_apt_install() { exit 1 ;; esac - sudo apt-get update -y /dev/null 2>&1 +} + _is_verbose() { [ "${UNSLOTH_VERBOSE:-0}" = "1" ] } @@ -1510,25 +1519,46 @@ if [ "$_NEED_LLAMA_SOURCE_BUILD" = true ] && grep -qi microsoft /proc/version 2> step "gguf deps" "installed" elif command -v sudo >/dev/null 2>&1; then step "gguf deps" "sudo required for: $_STILL_MISSING" "$C_WARN" - printf " %-15s" "" - printf "accept? [Y/n] " - if [ -r /dev/tty ]; then - read -r REPLY &2 + return 1 + fi echo "SUDO_RAN: $*" } # shellcheck disable=SC1090 @@ -199,6 +204,13 @@ _out=$(run_smart tty needspasswd) assert_contains "tty present: still prompts" "$_out" "Accept? [Y/n]" assert_contains "tty present: accepts and installs" "$_out" "SUDO_RAN: apt-get install -y cmake" +# Consent given at a real tty, but the elevated apt-get fails anyway (sudoers +# denial, wrong password, apt error). The interactive branch must say what to +# run by hand, like the headless branch does, not die on the bare sudo error. +_out=$(run_smart tty denied) +assert_contains "tty + denied sudo: gives the manual command" \ + "$_out" "sudo apt-get update -y && sudo apt-get install -y cmake" + # No sudo at all keeps its own message. _out=$(run_smart notty absent) assert_contains "no sudo binary: unchanged message" "$_out" "sudo is not available on this system"