mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-08 16:39:42 +02:00
fix: installer fails on macOS when piped via curl | bash
When running `curl | bash`, stdin is the pipe, not the terminal. Homebrew and sudo need TTY access to prompt for the password. Redirect /dev/tty as stdin for these subprocesses. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+15
-3
@@ -353,8 +353,15 @@ ensure_sudo() {
|
|||||||
die "sudo is required but not installed. Please install packages manually or run as root."
|
die "sudo is required but not installed. Please install packages manually or run as root."
|
||||||
fi
|
fi
|
||||||
# Validate sudo access
|
# Validate sudo access
|
||||||
if ! sudo -v 2>/dev/null; then
|
# When piped (curl | bash), stdin is the pipe — redirect from /dev/tty so sudo can prompt
|
||||||
die "Failed to obtain sudo privileges."
|
if [[ -e /dev/tty ]]; then
|
||||||
|
if ! sudo -v 2>/dev/null < /dev/tty; then
|
||||||
|
die "Failed to obtain sudo privileges."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if ! sudo -v 2>/dev/null; then
|
||||||
|
die "Failed to obtain sudo privileges. Try running the script directly instead of piping."
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -372,7 +379,12 @@ ensure_homebrew() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
info "Installing Homebrew first..."
|
info "Installing Homebrew first..."
|
||||||
/bin/bash -c "$(download_to_stdout https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
# When piped (curl | bash), stdin is the pipe — Homebrew needs TTY for sudo password prompt
|
||||||
|
if [[ -e /dev/tty ]]; then
|
||||||
|
/bin/bash -c "$(download_to_stdout https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" < /dev/tty
|
||||||
|
else
|
||||||
|
NONINTERACTIVE=1 /bin/bash -c "$(download_to_stdout https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||||
|
fi
|
||||||
|
|
||||||
# Add Homebrew to PATH for Apple Silicon
|
# Add Homebrew to PATH for Apple Silicon
|
||||||
if [[ -f /opt/homebrew/bin/brew ]]; then
|
if [[ -f /opt/homebrew/bin/brew ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user