Skip to content

Commit 2cba393

Browse files
Ark0Nclaude
andcommitted
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>
1 parent 64b8ea3 commit 2cba393

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

install.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,15 @@ ensure_sudo() {
353353
die "sudo is required but not installed. Please install packages manually or run as root."
354354
fi
355355
# Validate sudo access
356-
if ! sudo -v 2>/dev/null; then
357-
die "Failed to obtain sudo privileges."
356+
# When piped (curl | bash), stdin is the pipe — redirect from /dev/tty so sudo can prompt
357+
if [[ -e /dev/tty ]]; then
358+
if ! sudo -v 2>/dev/null < /dev/tty; then
359+
die "Failed to obtain sudo privileges."
360+
fi
361+
else
362+
if ! sudo -v 2>/dev/null; then
363+
die "Failed to obtain sudo privileges. Try running the script directly instead of piping."
364+
fi
358365
fi
359366
}
360367

@@ -372,7 +379,12 @@ ensure_homebrew() {
372379
fi
373380

374381
info "Installing Homebrew first..."
375-
/bin/bash -c "$(download_to_stdout https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
382+
# When piped (curl | bash), stdin is the pipe — Homebrew needs TTY for sudo password prompt
383+
if [[ -e /dev/tty ]]; then
384+
/bin/bash -c "$(download_to_stdout https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" < /dev/tty
385+
else
386+
NONINTERACTIVE=1 /bin/bash -c "$(download_to_stdout https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
387+
fi
376388

377389
# Add Homebrew to PATH for Apple Silicon
378390
if [[ -f /opt/homebrew/bin/brew ]]; then

0 commit comments

Comments
 (0)