Repository navigation
Conversation
`uv run rtk pytest` produced no output at all when pytest was missing from the venv: exit 1, a single newline on stdout, nothing on stderr. A test run that prints nothing and reports no error reads as a quiet pass, leaving the exit code as the only signal. The trigger is uv, but the defect is in the runner. Filters that compress stdout pass RunOptions::stdout_only, which keeps stderr out of the filter input — and run_captured_filter only ever emitted stderr inside its skip_filter_on_failure branch. Callers that pair stdout_only with early_exit_on_failure (ls, tree) hit that branch and print stderr; callers that don't (pytest, ruff, prettier, go test, golangci-lint, phpunit, phpstan, pint, rubocop) captured stderr and dropped it on the floor. Standalone `rtk pytest` looks fine only because python is absent there: the spawn fails outright and the anyhow error prints. Under `uv run` the venv supplies python, so rtk falls back to `python -m pytest`, the spawn succeeds, and the child's "No module named pytest" goes to the stderr that was being discarded. Emit stderr when the child fails. Only on failure: on a successful run stderr is the incidental noise RTK exists to suppress, and filtered stdout already carries the result. Fixes rtk-ai#3026
|
|
Adopt rtk-ai#3029: runner - surface failing tool's stderr under stdout-only filters
KuSh
left a comment
There was a problem hiding this comment.
Hi @georgyia,
Thanks for your contribution. You’ll need to sign the CLA before we can move forward.
A few notes on your PR:
This will break golangci_cmd.rs, since it deliberately behaves that way for the “lint issues found” case, and possibly rspec_cmd.rs too.
phpstan_cmd.rs would also duplicate diagnostics.
Also, result.raw_stderr is captured by stream.rs's CaptureOnly thread, which doesn't warn on truncation the way the other capture paths there do (stream.rs:376,384) — worth adding that same 10 MiB warning, since this PR is what makes that stderr visible to the user for the first time.
Most of this should be fixed by gating on stdout:
if opts.filter_stdout_only && exit_code != 0
&& result.raw_stdout.trim().is_empty()
&& !result.raw_stderr.trim().is_empty()
{
eprint!("{}", result.raw_stderr);
}The bug you’re trying to fix is really that stdout is empty or useless and the diagnostic is stuck in stderr, so this should only kick in when stdout is also empty. Most tools exit nonzero with populated stdout, which helps gate against a noise regression.
A few other points:
- Token-savings tracking (
raw_for_tracking/shown) doesn't include the new shown stderr bytes, so that should be fixed. - With those changes, you'll need a test covering the
stdoutnon-empty + nonzero exit + benignstderr→ no dump case. - Bonus: you could avoid
skip_filter_on_failureduplication by adding anemit_stderr_if_presenthelper.
|
Thanks for tracking this down, the writeup of why only the stdout_only plus no-early-exit combination went mute was exactly right. This landed on develop on 2026-09-12 in #3772, which forwards a stdout-only filter's stderr in the same place in run_captured_filter and also counts those bytes in the savings total. It forwards unconditionally rather than only on failure, because tools like prettier write their whole report to stderr on a successful run, so the one behaviour your PR pinned differently is a deliberate choice there. Closing as covered, but please comment or reopen if you see a case that still comes out silent. |
Fixes #3026
Problem
uv run rtk pytestsays nothing at all when pytest is missing from the venv — exit 1, a single newline on stdout, empty stderr. As the issue puts it, this is the dangerous quadrant: a test run that produces no output and no error text reads as a quiet pass, and the exit code is the only surviving signal.Root cause
uv is the trigger, not the culprit — and it isn't a spawn failure either.
Filters that compress stdout pass
RunOptions::stdout_only, which keeps stderr out of the filter input. Butrun_captured_filteronly ever emittedraw_stderrinside itsskip_filter_on_failurebranch. Callers that pairstdout_onlywithearly_exit_on_failure(ls,tree) reach that branch and print stderr; callers that don't captured stderr and dropped it:stdout_onlycallerearly_exit_on_failurels,treepytest,ruff,prettier,go test,golangci-lint,phpunit,phpstan,pint,rubocopWhy only the combination goes mute: standalone
rtk pytestlooks fine because python is absent, so the spawn fails outright and theanyhowerror prints loudly. Underuv runthe venv supplies python, so rtk takes itspython -m pytestfallback, the spawn succeeds, and the child's diagnostic goes to the stderr that was being discarded:Fix
Emit stderr when the child fails:
Only on failure — on a successful run stderr is the incidental noise RTK exists to suppress, and the filtered stdout already carries the result. This is the rule
ls/treealready get viaearly_exit_on_failure, applied to the callers that were missing it. No double-printing:FilterMode::CaptureOnlybuffers stderr without echoing, and theskip_filter_on_failurebranch returns before this point.This likely covers more than #3026. The table above is a family, and #2878 ("rtk prettier silently hides prettier 3 failures — stdout-only capture + [warn] filter") names this exact mechanism. I've deliberately scoped this PR to the shared runner defect and made no filter-specific claims; I haven't verified #2878 end-to-end, so I'm flagging the overlap rather than asserting a fix.
Verification
uv run rtk pytest --version(missing)No module named pytestuv run rtk pytest --version(installed)Reproduced against real
uvin a freshuv init+uv venvproject, both with and without pytest installed.tests/stderr_passthrough_test.rsput a failing shim onPATH(stderr message, empty stdout, nonzero exit) and drive it throughrtk ruff, a barestdout_onlycaller.failing_tool_stderr_reaches_the_userfails on the pre-fix runner and passes after;successful_tool_stderr_stays_suppressedpasses both ways, pinning that no new noise is introduced on success.cargo fmt --all --checkclean,cargo clippy --all-targetszero warnings,cargo test --all2495 passed / 0 failed.Verified on Linux (
rust:latest); the tests are#![cfg(unix)]as they rely on a shell shim andPermissionsExt.Test plan
cargo fmt --all && cargo clippy --all-targets && cargo test --alluv run rtk pytest --versionwith and without pytest in the venv