Skip to content

Stop the post-start hook prompting and hanging ddev start - #22

Open
mortona42 wants to merge 1 commit into
FreelyGive:mainfrom
mortona42:fix-post-start-hook-prompt-hang
Open

Stop the post-start hook prompting and hanging ddev start#22
mortona42 wants to merge 1 commit into
FreelyGive:mainfrom
mortona42:fix-post-start-hook-prompt-hang

Conversation

@mortona42

Copy link
Copy Markdown

Fixes #21.

From claude:

The README says the post-start hook runs ddev claude-update in report-only mode, but the hook passed no flags and the command's "am I interactive?" guard was only [ -t 0 ]. Inside a DDEV exec-host hook stdin is still a tty, so the guard passed and the command printed its [i/p/c] menu and blocked on read -- freezing the ddev start that spawned it (and, when the start was triggered implicitly, the ddev claude behind it). Answering did not free it: [i] shells out to a nested ddev exec and [p] execs ddev restart --no-cache, both from inside a start still in progress.

CI never caught it because bats runs with stdin on a pipe, where the old guard happened to do the right thing.

  • Pass -n in the hook so the documented report-only behaviour is what the hook actually asks for, rather than a side effect of tty detection.
  • Require a tty on stdout as well as stdin before prompting, so any other caller that captures our output degrades to a report instead of hanging.
  • Let DDEV_CLAUDE_CODE_AUTOUPDATE override -n, so opting into auto-updates still works now that the hook passes that flag.
  • Cover the env-var-beats--n path in tests/test.bats.

The Issue

  • Fixes #REPLACE_ME_WITH_RELATED_ISSUE_NUMBER

How This PR Solves The Issue

Manual Testing Instructions

ddev add-on get https://github.com/FreelyGive/ddev-claude-code/tarball/refs/pull/REPLACE_ME_WITH_THIS_PR_NUMBER/head
ddev restart

Automated Testing Overview

Release/Deployment Notes

The README says the post-start hook runs `ddev claude-update` in report-only
mode, but the hook passed no flags and the command's "am I interactive?" guard
was only `[ -t 0 ]`. Inside a DDEV `exec-host` hook stdin is still a tty, so
the guard passed and the command printed its `[i/p/c]` menu and blocked on
`read` -- freezing the `ddev start` that spawned it (and, when the start was
triggered implicitly, the `ddev claude` behind it). Answering did not free it:
`[i]` shells out to a nested `ddev exec` and `[p]` `exec`s
`ddev restart --no-cache`, both from inside a start still in progress.

CI never caught it because bats runs with stdin on a pipe, where the old guard
happened to do the right thing.

- Pass `-n` in the hook so the documented report-only behaviour is what the
  hook actually asks for, rather than a side effect of tty detection.
- Require a tty on stdout as well as stdin before prompting, so any other
  caller that captures our output degrades to a report instead of hanging.
- Let DDEV_CLAUDE_CODE_AUTOUPDATE override `-n`, so opting into auto-updates
  still works now that the hook passes that flag.
- Cover the env-var-beats-`-n` path in tests/test.bats.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018SEQ1aLYbhpWkgNNhTXcE4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude update command hangs

1 participant