Skip to content

rtk tree on Windows passes Unix flags to tree.com and reports its errors as success #3434

Open

Description

@HetCreep

Two findings from comparing rtk against the real tools.

Provenance: AI-assisted source audit, human-directed, at v0.44.2 (700bdde). Both reproduced on Windows with the shipped binary; outputs verbatim.

1. rtk ls hides directories without saying so

A directory containing build coverage dist node_modules normaldir target venv:

$ ls
build coverage dist node_modules normaldir target venv

$ rtk ls
normaldir/

Six of seven directories are gone. No count, no +N more, nothing.

They do exist, and rtk knows it:

$ rtk ls -a
build/ coverage/ dist/ node_modules/ normaldir/ target/ venv/

$ rtk ls dist
out.js  2B

src/cmds/system/ls.rs:266 filters against NOISE_DIRS (src/core/constants.rs:1-27).

Suppressing node_modules from a listing is a reasonable default. Doing it with no marker is the problem — a reader concludes the build has not run, the venv was never created, or dist/ does not exist. That conclusion is wrong and nothing in the output hints at it.

Contrast rtk's own behaviour elsewhere: the result cap in rtk find prints +450 more, and rtk read prints [N more lines]. The convention exists; this path just does not use it.

A single line — (6 build/tooling directories hidden; -a to show) — would preserve the compression and remove the false impression.

2. rtk tree on Windows invokes tree.com with Unix flags

$ rtk tree
Too many parameters - node_modules|.git|target|__pycache__|.next|dist|build|.cache|…
exit=0

src/cmds/system/tree.rs:15 checks tool_exists("tree"), which matches Windows' built-in tree.com — an unrelated program that takes no -I flag. :25-32 then passes the ignore pattern, and tree.com rejects the whole invocation.

With -a, the same review observed Invalid path - …\-A followed by No subfolders exist in a directory that has eight — an affirmatively wrong statement, also at exit 0.

Both cases exit 0, so a caller sees a successful command that produced an error message as its "output".

.claude/rules/cli-testing.md lists Windows as a supported platform, and the release workflow ships a Windows binary.

Suggested directions (untested — no programmer has reviewed these)

  1. Emit a one-line notice when entries are suppressed, and mention -a. Alternatively suppress only inside a project root where those names are unambiguous, and list them normally elsewhere.
  2. On Windows, either detect that the resolved tree is tree.com (its output and flags are distinct) and fall back to rtk's own walker, or skip the external tool entirely there. tool_exists matching an unrelated same-named program is worth checking for other commands too — find and sort have Windows built-ins of the same name.

Related

The rtk ls shape here is the same family as #3432's hidden-path filtering in rtk find: a default exclusion that is invisible in the output. They are different code paths (NOISE_DIRS vs the walker's .hidden()), which is why I am filing them separately, but a single convention for "we excluded things, here is how many" would cover both.

Activity

  1. pszymkowiak commented on Aug 4, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 90%

    Summary

    rtk ls silently drops NOISE_DIRS entries with no count/marker, and on Windows rtk tree resolves to the built-in tree.com (which rejects Unix flags like -I/-a) yet still exits 0 while printing an error or a false 'No subfolders exist' — needs a suppression notice in ls and Windows-aware tool detection/fallback in tree.

    📁 Relevant files
    • src/cmds/system/ls.rs
    • src/core/constants.rs
    • src/cmds/system/tree.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  2. HetCreep commented on Sep 16, 2026

    @HetCreep
    Author

    Re-checked this against develop at 5e0f92c (confirmed current tip via a fresh git fetch against origin). The verdict is now split — one claim is fixed, the other is not.

    Claim 1 (rtk ls silently hides noise dirs) — fixed. Thanks for this.

    src/cmds/system/ls.rs:316-319 still filters on NOISE_DIRS membership (a generic membership check, not hardcoded to the specific names in the original report):

    if !show_all && NOISE_DIRS.iter().any(|noise| name == *noise) {
        filtered.push(format!("{}/", name));
        continue;
    }

    but it's no longer silent. run() now feeds the result into hidden_hint() (ls.rs:117-120), which unconditionally appends a "... (N filtered)" note (ls.rs:154) plus a tee-backed recovery command whenever anything was dropped. git log --oneline 0de9610..5e0f92c -- src/cmds/system/ls.rs shows 5 commits against this file, including 67a3576 ("cap listing with tee tail hint and standard dotfile semantics") and a7e7329 ("record dot noise dirs under -A and track real args") — git merge-base --is-ancestor puts both strictly after the 0de9610 checkpoint our prior read of this issue used, so this is a genuine fix landed since, not something missed earlier. The original concern — a reader has no way to tell anything was hidden — no longer applies. Fine to treat this half as closed.

    Claim 2 (rtk tree feeds Unix -I/-a to Windows' tree.com) — still open. Please don't close this issue.

    src/cmds/system/tree.rs has zero commits in the same range (git log --oneline 0de9610..5e0f92c -- src/cmds/system/tree.rs is empty), and the mechanism is unchanged from the original report:

    • tree.rs:15 gates on tool_exists("tree"), which is which::which(name).is_ok() (core/utils.rs:602) and is documented in its own comment as "PATHEXT-aware on Windows" — on Windows that resolves to the OS's built-in tree.com, not GNU tree.
    • tree.rs:27-33 unconditionally appends -I <NOISE_DIRS joined with |> unless the caller already passed -a/--all/-I/--ignore=.
    • Neither tree.rs nor runner::run_filtered (src/core/runner.rs, which has no Windows-specific branch anywhere in it) checks the target OS or inspects the child's stdout before trusting its exit code.

    tree.com doesn't recognize -I/-a — the flags this code always injects reach a binary that can't parse them, and nothing in the pipeline catches that. The exit-0-with-wrong-output behavior described in the original report is still live on this exact code path.

    Also correcting our own citation while we're here: the original report pointed to NOISE_DIRS at src/core/constants.rs:1-27. That was wrong at the time it was written, not something that changed since — NOISE_DIRS has always lived at src/cmds/system/constants.rs:1 (a single definition, confirmed by grep). src/core/constants.rs holds unrelated constants (RTK_DATA_DIR, HISTORY_DB, etc.). Flagging it since claim 2 above cites the same constant.

    This pass is based on reading the code and commit history at 5e0f92c, not on building or running the binary.

  3. HetCreep commented on Oct 14, 2026

    @HetCreep
    Author

    Re-checked on v1.0.0 (stable, 2026-10-13): the official release binary plus the v1.0.0 source. Provenance: AI-assisted check, human-directed. "ran" = executed against rtk 1.0.0 with a control; "read" = verified from source only.

    Fixed (ran): the ls half. rtk ls in a directory with build coverage dist node_modules target venv now prints normaldir/, ... (6 filtered) and [+6 hidden: rtk recall ...], so the omission is no longer silent. Thanks.

    Still live (ran on Windows): rtk tree feeds Unix flags to C:\Windows\System32\tree.com: rtk tree exits 0 with Too many parameters - node_modules|.git|target|..., rtk tree -a exits 0 with Invalid path - ...\-A / No subfolders exist, rtk tree -L 1 the same. Control: tree /F lists the directory fine. src/cmds/system/tree.rs:16 still uses tool_exists("tree") (which::which) with no tree.com guard, and -I is still pushed at :27-31.

  4. PranjalAgarwal01 commented on Oct 28, 2026

    @PranjalAgarwal01

    Confirming on Windows 11 + PowerShell 7 with RTK 1.1.0:

    • rtk ls → Failed to resolve 'ls' via PATH ... Binary 'ls' not found on PATH
    • rtk ps and rtk wc → the same “binary not found” failure
    • rtk tree → Windows tree.com: Too many parameters - node_modules|.git|target|...

    This is especially visible through the OpenCode plugin: it rewrites ls/ps/wc/tree before execution, so a working PowerShell alias becomes a failed command.

    Local workaround: [hooks] exclude_commands = ["ls", "tree", "wc", "ps", "wget", "diff"].

    The native Windows/PowerShell routing PRs (#2875, #3301, #2728) would address this. Please also make the rewrite host-aware so aliases without native binaries are left untouched on Windows.

  5. KuSh commented on Oct 31, 2026

    @KuSh
    Collaborator

    Re-checked on v1.1.0 and develop:

    • The ls half is fixed since v1.0.0, as confirmed in the 10-14 comment: hidden noise directories are counted (... (6 filtered)) with a recall hint. On develop, after fix(ls): hold a bare listing to what ls prints, not to the long listing rtk asks for #4833 (not in a release yet), rtk ls lists all seven directories of the original example.
    • The tree half is unchanged: src/cmds/system/tree.rs still gates on tool_exists("tree"), which resolves to tree.com on Windows, and still appends -I <noise dirs>. This is read from the code (no Windows host here); the 10-28 comment shows the same Too many parameters on 1.1.0.
    • The ls, ps and wc "binary not found" failures in the 10-28 comment are a different defect (PowerShell aliases with no executable on PATH), covered by [BUG] RTK Windows PowerShell Compatibility Gaps #1248.

    Narrowing this issue to the tree half would match what is left, for example "rtk tree on Windows passes Unix flags to tree.com and reports its errors as success".

  6. changed the title [-]`rtk ls` silently omits build/dist/target/coverage/venv/node_modules — no count, no marker — and `rtk tree` feeds Unix flags to Windows' `tree.com`, reporting "No subfolders exist" as success[/-] [+]`rtk tree` on Windows passes Unix flags to tree.com and reports its errors as success[/+] on Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions