Skip to content

Commit a7afc5c

Browse files
fix(install): handle piped execution without TTY properly
- can_prompt() now checks if /dev/tty is actually accessible, not just exists - Print NEEDS_USER_INPUT when no TTY available (piped via setsid) Co-authored-by: Venkat SF <venkatesh.sakamuri@stayflexi.com>
1 parent 49db5a0 commit a7afc5c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎scripts/self-host/install.sh‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,11 @@ generate_secret() {
349349

350350
# Check if we can prompt interactively
351351
can_prompt() {
352-
[[ "$NON_INTERACTIVE" -eq 0 ]] && [[ -e /dev/tty ]]
352+
# Non-interactive mode disables prompts
353+
[[ "$NON_INTERACTIVE" -eq 1 ]] && return 1
354+
# Check if /dev/tty is actually accessible (not just exists)
355+
# When piped via setsid, /dev/tty exists but cannot be opened
356+
[[ -r /dev/tty ]] && [[ -w /dev/tty ]] && : </dev/tty 2>/dev/null
353357
}
354358

355359
# Prompt for a value, reading from /dev/tty if available
@@ -842,7 +846,8 @@ main() {
842846
echo
843847
echo "No LLM key configured. Chat and AI features will be disabled."
844848
echo "Configure your LLM key during onboarding in the web UI after logging in."
845-
if [[ "$NON_INTERACTIVE" -eq 1 ]]; then
849+
# Print machine-readable output when non-interactive OR when no TTY available
850+
if [[ "$NON_INTERACTIVE" -eq 1 ]] || ! can_prompt; then
846851
echo "NEEDS_USER_INPUT: DEEPSQL_LLM_API_KEY (optional, can be set during onboarding at http://localhost:${DEEPSQL_FRONTEND_PORT:-3000})"
847852
fi
848853
fi

0 commit comments

Comments
 (0)