Skip to content

ENOENT (os error 2) blocks rtk json (stdin), rtk smart <cmd>, rtk telemetry — likely shared arg-parsing bug #2095

Open

Description

@LMS927369

Summary

Three subcommands fail identically with [rtk: No such file or directory (os error 2)] immediately upon invocation. The symptom is the same; the root cause is almost certainly a shared argument-parsing/file-lookup defect.

Environment

  • rtk 0.42.0 (Homebrew, installed 2026-05-24)
  • macOS Darwin 24.6.0 (x86_64)
  • zsh 5.9
  • rtk verify reports 145/145 inline tests passed and hook integrity OK

Bug A: rtk json rejects stdin input

$ echo '{"a":1,"b":2}' | rtk json
[rtk: No such file or directory (os error 2)]

Expected: Compact-format the JSON read from stdin (per rtk help json).
Actual: ENOENT, apparently because the wrapper requires a file argument and never falls back to stdin.

Workaround: pass a file path arg (rtk json file.json). Loses the pipe use case (e.g., kubectl get -o json | rtk json).

Bug B: rtk smart <cmd> errors with ENOENT

$ rtk smart cat /Users/master/.claude/RTK.md
[rtk: No such file or directory (os error 2)]

Expected: Run the inner command and emit a 2-line heuristic summary (per rtk help smart).
Actual: ENOENT before the inner command runs. Looks like the wrapper resolves cat as a file path rather than as a command to wrap.

Workaround: use rtk summary <cmd> — that wrapper works as expected.

Bug C: rtk telemetry returns ENOENT

$ rtk telemetry
[rtk: No such file or directory (os error 2)]

Expected: Show telemetry consent state, allow opt-in/opt-out (per rtk help telemetry: "Manage telemetry consent and data (RGPD/GDPR)").
Actual: ENOENT immediately.

Note: the [telemetry] section IS readable via rtk config (default enabled=false, consent_given=false), so the underlying state mechanism works — only the dedicated subcommand is broken.

Workaround: edit ~/Library/Application Support/rtk/config.toml under [telemetry] directly.

Hypothesis: shared root cause

All three commands fail with the same errno-2 message at the exact same point (before any subcommand-specific logic runs). Suggests a shared arg-parsing/file-lookup helper that's mistakenly treating the first positional argument (or implied input source) as a file path. Fixing one will likely fix all three.

Validation status

rtk help json, rtk help smart, rtk help telemetry all return successfully — the subcommands ARE registered in the help system. Only the runtime path fails. Other subcommands (rtk ls, rtk wc, rtk grep, rtk find, rtk git, rtk env, rtk read, rtk diff, rtk gh, rtk docker, rtk kubectl, rtk go, rtk gain, rtk session, rtk learn, rtk discover, rtk verify, rtk rewrite, rtk hook-audit, rtk config) all work correctly on this same setup.

Activity

  1. pszymkowiak commented on May 27, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟠 Priority high
    🎯 Confidence 91%

    Summary

    Three subcommands (json stdin, smart, telemetry) fail with ENOENT before executing; reporter hypothesizes a shared arg-parsing bug — investigate and fix the shared file-lookup path.


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

  2. KuSh commented on Aug 30, 2026

    @KuSh
    Collaborator

    Re-ran all three reproductions on 0.46.0 (develop @ cf6d99d). The shared ENOENT has largely gone, but one case survives — and it is a command not listed here.

    as filed (0.42.0) 0.46.0
    A rtk json (stdin) ENOENT exit 2, clap: the following required arguments were not provided: <FILE> diagnosis fixed, gap remains
    B rtk smart <cmd> ENOENT exit 2, clap: unexpected argument 'f.md' found not a bug — see below
    C rtk telemetry ENOENT exit 2, prints its own help correct behaviour
    D rtk read (no args) not reported exit 127, [rtk: No such file or directory (os error 2)] still live

    D — the one still reproducing

    $ printf 'piped\n' | rtk read
    [rtk: No such file or directory (os error 2)]
    $ echo $?
    127

    This is the exact symptom the issue is named after, and it is the last instance of it. files is declared #[arg(required = true, num_args = 1..)], so clap rejects the no-argument form and run_fallback (src/main.rs:1293) takes over and tries to execute read as a raw command. There is no read binary — it is a shell builtin — hence ENOENT and the shell's 127 "command not found" convention.

    rtk log shows what the working shape looks like: its file is Option<PathBuf>, so printf 'ERROR x\n' | rtk log reads stdin and exits 0.

    Worth noting rtk read - and rtk json - both work correctly today, so the explicit-dash form is a usable workaround for A and D.

    B is not a bug

    rtk smart takes a file, not a command to wrap:

    Usage: rtk smart [OPTIONS] <FILE>
    
    Arguments:
      <FILE>  File to analyze
    

    rtk smart cat /path/file was therefore two positionals where one was expected. rtk summary <cmd> — the workaround in the original report — is the command wrapper. Errors are also clean now: rtk smart nosuchfile.md exits 1 with rtk: Failed to read file: nosuchfile.md: No such file or directory, naming the file.

    If rtk help smart implied command-wrapping at 0.42.0, that wording is gone; the current help is unambiguous.

    C is correct clap behaviour

    rtk telemetry requires one of status / enable / disable / forget. Printing the subcommand help and exiting 2 is what clap should do for a missing required subcommand.

    Suggestion

    Narrow this issue to D (rtk read with no arguments falls through to raw execution) plus, if still wanted, the A feature gap (accept stdin when no file is given, as rtk log does). B and C look resolved and could be struck from the description so the remaining work is visible.

    Happy to be corrected if any of these still reproduce on macOS — everything above was measured on Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions