Skip to content

fix: route wt --version output to stdout#2073

Merged
max-sixty merged 1 commit intomainfrom
fix/issue-2072
Apr 11, 2026
Merged

fix: route wt --version output to stdout#2073
max-sixty merged 1 commit intomainfrom
fix/issue-2072

Conversation

@worktrunk-bot
Copy link
Copy Markdown
Collaborator

Problem

wt --version wrote to stderr instead of stdout, breaking scripts like version=$(wt --version). The reporter hit this while packaging wt as a devcontainer feature and had to work around it with wt --version 2>&1 in a test.

The root cause is in src/help.rs: clap's DisplayVersion error was rendered via eprint\! with the comment "stdout is reserved for data/scripts". But --version output is data that scripts rely on — POSIX convention (and clap's own default when it handles parsing itself) is that --version goes to stdout. Only errors and diagnostics go to stderr.

Solution

Change eprint\! to print\! in the DisplayVersion branch of maybe_handle_help_with_pager, and update the comment to explain the POSIX rationale. No change to DisplayHelp (help text goes through the pager path, which correctly uses stdout when a pager isn't available via show_help_in_pager).

Testing

  • Added test_version_goes_to_stdout in tests/integration_tests/help.rs that asserts stdout contains "wt " and stderr is empty. Verified the test fails against the buggy code and passes with the fix.
  • Updated the existing test_version snapshot (tests/snapshots/integration__integration_tests__help__version.snap), which had been capturing the buggy behavior (stdout empty, version on stderr).
  • Full integration suite: cargo test --test integration — 1416 passed.
  • cargo clippy --all-targets -- -D warnings and cargo fmt --check clean.

Closes #2072 — automated triage

clap's DisplayVersion error was rendered via `eprint\!` with the comment
"stdout is reserved for data/scripts" — but `--version` output _is_ data
that scripts rely on. POSIX convention (and the clap default when it
handles parsing itself) is that `--version` goes to stdout.

This broke scripts like `version=$(wt --version)` and the devcontainer
feature test in the reporter's PR, which had to be updated to
`wt --version 2>&1` as a workaround.

Closes #2072

Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty max-sixty merged commit 8742c3a into main Apr 11, 2026
23 checks passed
@max-sixty max-sixty deleted the fix/issue-2072 branch April 11, 2026 14:13
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.

wt --version outputs to stderr

2 participants