install.sh:275 exec zsh ignores PAI_TEST_AUTOMATED=1 and assumes zsh is installed
Summary
install.sh:275 hardcodes exec zsh -i -c 'source ~/.zshrc && pai' < /dev/tty at the end of the post-wizard handoff path. Two failure modes:
PAI_TEST_AUTOMATED=1doesn't suppress the exec. The env var gatesINSTALL_MODEat line 237 but does not gate the post-wizard handoff. On CI / automation runners where/dev/ttyis still readable, the scriptexecs into zsh and never returns control to the parent.zshis hardcoded. On systems where the user's default shell is bash andzshis not installed at all (common on Ubuntu / WSL2),exec zsherrors out withzsh: command not foundafter a successful install — making it look like the installer failed.
Repro (failure mode 1 — automation hang)
SHELL=/bin/bash PAI_TEST_AUTOMATED=1 bash install.sh
# Wizard runs, exits 0.
# Script reaches line 275: exec zsh -i -c '...' < /dev/tty
# On Linux/WSL2 with /dev/tty readable, exec succeeds.
# Parent (CI runner / piped consumer) never sees install.sh exit.
Repro (failure mode 2 — bash user without zsh)
# Ubuntu 24.04 fresh, only bash installed:
bash install.sh
# Wizard runs fine.
# Line 275: exec zsh ...
# zsh: command not found
# (install.sh's success message at line 277 also never prints because exec replaced the process)
Expected
The post-wizard handoff at lines 270-279 should:
- Skip
exec zshwhenPAI_TEST_AUTOMATED=1(CI/automation must exit cleanly) - Honor the user's actual shell rather than assuming zsh
- Fall through cleanly to the "run manually" branch when zsh isn't installed
Suggested fix
if [ "$INSTALL_EXIT" -eq 0 ]; then
echo ""
- if [ -r /dev/tty ]; then
+ if [ -r /dev/tty ] && [ "${PAI_TEST_AUTOMATED:-}" != "1" ] && command -v zsh > /dev/null; then
info "Launching pai..."
exec zsh -i -c 'source ~/.zshrc && pai' < /dev/tty
else
info "Install complete. To start pai, run: ${BOLD}source ~/.zshrc && pai${RESET}"
fi
fi
Three gates, all needed for CI/automation/bash-user cases. The comment block at lines 257-268 explains why exec is desired in the interactive path — that intent is preserved; we just narrow it to "interactive + zsh-available + not-automated".
If zsh-only handoff is intentional doctrine (because pai alias is documented zsh-style), the alternative is to detect $SHELL and exec "$SHELL" -i -c 'source $rcfile && pai'. That mirrors the multi-shell rc-file loop already present at line 182.
Environment
- PAI v5.0.0 (current main,
install.shfromReleases/v5.0.0/.claude/install.sh) - Ubuntu 24.04 on WSL2, bash 5.2.21
PAI_TEST_AUTOMATED=1 bash install.shreproduced the hang reliably across 3 invocations
Related
- #1184 —
~/.bash_profileshadowing on Ubuntu/WSL (same install.sh, bash-on-Linux assumption) - PR #1152 (closed/private-merged) — already covers the validator's multi-shell alias scan; this issue is the next-door bug in the same script
Hey — Kai here.
Thanks. Your three-gate pattern is now in the upstream install.sh:
if [ -r /dev/tty ] && [ "${PAI_TEST_AUTOMATED:-}" != "1" ] && command -v zsh > /dev/null 2>&1; then
[ -r /dev/tty ]stays for the interactive handoff (the existing reason — needed forcurl | shso the inherited shell gets a real TTY).[ "${PAI_TEST_AUTOMATED:-}" != "1" ]lets CI/automation harnesses exit cleanly with the install exit status instead of gettingexec'd into a shell they can't read.command -v zsh > /dev/null 2>&1falls through to the "run manually" branch on bash-only systems instead of thezsh: command not foundfailure that looks like an install error.
Verified bash -n on the script — syntax clean. The intent of the original exec zsh path (interactive handoff under curl | sh) is preserved; we just narrow it to "interactive AND zsh-available AND not-automated."
The alternate path you mentioned (exec "$SHELL" -i -c 'source $rcfile && pai' mirroring the multi-shell rc-file loop earlier in the script) is the right second step if/when we want bash users to land in their own shell after install — but it requires the pai alias to be sourced into bash too, which is its own loop. Keeping that out of scope here.
Ships with the next release. Closing as fixed.
— Kai