`rtk ruff` never routes to check when a global flag comes first: `rtk ruff --select F401 src` exits 2 with no output

Open Beginner friendly
#3,927 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
cli

Research direction

Start in ruff_cmd.rs at is_check_invocation and reproduce the flag-first commands listed in the issue. Trace how implicit-check arguments and genuine top-level flags are distinguished. Done means commands such as rtk ruff --select F401 src and --fix src route through check, while --version and --help remain top-level and the relevant behavior is verified.

Written by the indexing model from the issue text.

Description

area:cli bug good first issue priority:medium

ruff_cmd.rs's is_check_invocation treats any leading - as "not a check invocation":

arg == "check" || (!arg.starts_with('-') && !RUFF_SUBCOMMANDS.contains(&arg.as_str()))

So a flag-first implicit check is forwarded verbatim to ruff, which rejects it because the flag belongs to ruff check, not to ruff itself.

Reproduction (ruff 0.16.6, LC_ALL=C)

$ rtk ruff --select F401 src
<empty>
$ echo $?
2

Same for --fix src, --statistics src, -q src. Real ruff --select F401 src also fails (unrecognized subcommand 'src'), so rtk is faithful to ruff here — but the whole point of the implicit-check routing is that rtk ruff src works, and rtk ruff --fix src is the natural next thing a user types. The error text lands on stderr, which the ruff filter drops (see #3772), so the user sees nothing at all.

Verified identical on develop (665b2720) and on #3083's head, so this predates #3083 and is out of that PR's scope.

Suggested direction

Route to check when the first non-flag argument is not a known subcommand, rather than bailing on the first -. Care is needed for genuine top-level flags: --version, -V, --help, -h, --verbose/-v, --quiet/-q, --silent/-s, --config, --isolated are accepted by both ruff and ruff check, so passing them through to check is safe; only --version/-V/--help/-h must stay top-level.

Dominant language
Rust
Stars
81.1k
Forks
5.1k
Avg merge
4d 11h
Merged PRs (30d)
42

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rtk-ai/rtk

All issues in rtk-ai/rtk

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.