Summary
When the system locale is not English (e.g. LANG=es_ES.UTF-8), rtk ls <dir> reports a directory as empty even when it contains many files. Likely affects other filters too.
Reproduce
$ LANG=es_ES.UTF-8 rtk ls /tmp
(empty)
$ LANG=es_ES.UTF-8 rtk ls -v /tmp
Chars: 8635 → 8 (100% reduction)
(empty)
$ LC_ALL=C rtk ls /tmp
.ICE-unix/
.X11-unix/
...
Tested on rtk 0.35.0 (master, commit 314978cd), Linux, LANG=es_ES.UTF-8.
Root cause
src/cmds/system/ls.rs uses a hardcoded English-month regex as the anchor for parsing ls -la rows:
static ref LS_DATE_RE: Regex = Regex::new(
r"\s+(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+\d{1,2}\s+(?:\d{4}|\d{2}:\d{2})\s+"
).unwrap();
src/core/runner.rs::run_filtered spawns the native subprocess without overriding locale, so on non-English systems ls -la emits month names in the user's language (ene feb mar abr… in Spanish). The regex never matches, compact_ls returns no entries, and the filter prints (empty).
Impact
Not just cosmetic — the LLM agent receives (empty) and may reasonably conclude the directory has no files. In my setup Claude Code was being told that directories with 40+ real files were empty. Silent data corruption for the agent's worldview is arguably worse than a visible error, because the agent will act on the wrong information.
Likely affects any other filter whose regexes assume English output from subcommands (git with LC_MESSAGES, find, stat, etc.).
Suggested fix
One-line patch in src/core/runner.rs::run_filtered, right before cmd.output():
cmd.env(\"LC_ALL\", \"C\");
Forces all filtered subcommands to emit C-locale output, which matches the existing English regexes. A single fix covers every filter that goes through run_filtered, so it prevents the same bug from appearing in other commands later.
I verified locally against rtk ls, rtk find, rtk grep, rtk git status — all keep working and the (empty) issue goes away.
Deliberately not applying the same env override to run_passthrough, since there the output is shown verbatim to the user and should respect their real locale.
Environment
- rtk 0.35.0 (master, commit
314978cd)
- OS: Linux (Ubuntu-family)
- Locale:
LANG=es_ES.UTF-8, all LC_* in Spanish
Happy to open a PR if helpful.
Summary
When the system locale is not English (e.g.
LANG=es_ES.UTF-8),rtk ls <dir>reports a directory as empty even when it contains many files. Likely affects other filters too.Reproduce
Tested on rtk 0.35.0 (master, commit
314978cd), Linux,LANG=es_ES.UTF-8.Root cause
src/cmds/system/ls.rsuses a hardcoded English-month regex as the anchor for parsingls -larows:src/core/runner.rs::run_filteredspawns the native subprocess without overriding locale, so on non-English systemsls -laemits month names in the user's language (ene feb mar abr…in Spanish). The regex never matches,compact_lsreturns no entries, and the filter prints(empty).Impact
Not just cosmetic — the LLM agent receives
(empty)and may reasonably conclude the directory has no files. In my setup Claude Code was being told that directories with 40+ real files were empty. Silent data corruption for the agent's worldview is arguably worse than a visible error, because the agent will act on the wrong information.Likely affects any other filter whose regexes assume English output from subcommands (git with
LC_MESSAGES,find,stat, etc.).Suggested fix
One-line patch in
src/core/runner.rs::run_filtered, right beforecmd.output():Forces all filtered subcommands to emit C-locale output, which matches the existing English regexes. A single fix covers every filter that goes through
run_filtered, so it prevents the same bug from appearing in other commands later.I verified locally against
rtk ls,rtk find,rtk grep,rtk git status— all keep working and the(empty)issue goes away.Deliberately not applying the same env override to
run_passthrough, since there the output is shown verbatim to the user and should respect their real locale.Environment
314978cd)LANG=es_ES.UTF-8, allLC_*in SpanishHappy to open a PR if helpful.