Skip to content

fix(cli): init crashed instead of setting up when there is no terminal - #6

Merged
ruleofcodedev merged 1 commit into
developfrom
bugfix/init-without-a-terminal
Aug 7, 2026
Merged

fix(cli): init crashed instead of setting up when there is no terminal#6
ruleofcodedev merged 1 commit into
developfrom
bugfix/init-without-a-terminal

Conversation

@ruleofcodedev

Copy link
Copy Markdown
Contributor

ruleofcode init asks its questions through inquirer, which needs a real terminal to answer them. In CI, in a container, or behind a pipe there is none: readline force-closes and the process dies with an ERR_USE_AFTER_CLOSE stack trace and exit 7 — a setup tool crashing rather than setting anything up. The site tells new users to run exactly this command.

Three behaviours now, each of them stated out loud:

  • no terminal, no config yet: run the same defaults --quick documents, and say so rather than pretend the user chose them;
  • no terminal, config already there: refuse, and point at --force. Overwriting a tuned config because nobody was present to object is the destructive answer to the question;
  • --force still overwrites, terminal or not.

The terminal requirement belongs to inquirer, so a caller that injects its own prompt function is unaffected.

Verified end to end against the packed tarball in a fresh consumer, which is where the crash was found.

What this changes

Verdict impact

  • No verdict change (docs, tests, refactor, internal)
  • Changes verdicts — a detector now catches more, or fewer, real cases
  • BREAKING — a default severity, threshold, or config shape changed
    (then: state the before/after values and what a consumer must do)

Evidence

  • Proven red: it flags the violation it claims to flag
  • Proven green: it passes correct code (no false positive)
  • Regression test added under tests/
  • detectionLimits updated if what the detector cannot see has changed

Gate

  • npm run lint — 0 errors
  • npx jest — full suite green
  • npm run canary — red/green proven across stacks
  • node dist/cli.js audit — RuleOfCode still passes its own law

Notes for the reviewer

`ruleofcode init` asks its questions through inquirer, which needs a
real terminal to answer them. In CI, in a container, or behind a pipe
there is none: readline force-closes and the process dies with an
ERR_USE_AFTER_CLOSE stack trace and exit 7 — a setup tool crashing
rather than setting anything up. The site tells new users to run
exactly this command.

Three behaviours now, each of them stated out loud:
- no terminal, no config yet: run the same defaults `--quick`
  documents, and say so rather than pretend the user chose them;
- no terminal, config already there: refuse, and point at --force.
  Overwriting a tuned config because nobody was present to object is
  the destructive answer to the question;
- --force still overwrites, terminal or not.

The terminal requirement belongs to inquirer, so a caller that injects
its own prompt function is unaffected.

Verified end to end against the packed tarball in a fresh consumer,
which is where the crash was found.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ruleofcodedev
ruleofcodedev merged commit 19376d4 into develop Aug 7, 2026
1 check passed
@ruleofcodedev
ruleofcodedev deleted the bugfix/init-without-a-terminal branch August 7, 2026 15:25
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.

1 participant