Skip to content

fix(ls): force LC_TIME=C for locale-independent date parsing#1689

Open
lakewaban wants to merge 1 commit intortk-ai:masterfrom
lakewaban:fix/ls-locale-date-parsing
Open

fix(ls): force LC_TIME=C for locale-independent date parsing#1689
lakewaban wants to merge 1 commit intortk-ai:masterfrom
lakewaban:fix/ls-locale-date-parsing

Conversation

@lakewaban
Copy link
Copy Markdown

@lakewaban lakewaban commented May 3, 2026

The LS_DATE_RE regex expects English month names (Jan, Feb, etc.), but ls -la output uses numeric months (5, 6, etc.) when the user's locale sets LC_TIME to a non-English language.

This causes parse_ls_line() to fail on every line, making rtk ls always return '(empty)' on such systems (e.g. Chinese locale).

Fix by setting LC_TIME=C before executing ls, ensuring the date format is always 'May 3 12:23' regardless of system locale.

Fixes #(issue number if known)

Summary

  • Force LC_TIME=C in the ls command environment so that ls -la output always uses English month names, matching the LS_DATE_RE regex in parse_ls_line()
  • Fixes rtk ls returning (empty) on systems with non-English locales (e.g. zh_CN.UTF-8)

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • LC_TIME=zh_CN.UTF-8 rtk ls should now show files instead of (empty)
  • rtk ls with default English locale still works correctly
  • Manual testing: rtk ls output inspected on both English and Chinese locale

Important: All PRs must target the develop branch (not master).
See CONTRIBUTING.md for details.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 3, 2026

CLA assistant check
All committers have signed the CLA.

@lakewaban
Copy link
Copy Markdown
Author

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.6 out of 7 committers have signed the CLA.✅ vsumner✅ JBF1991✅ aeppling✅ lakewaban✅ swithek✅ KuSh❌ dependabot[bot]You have signed the CLA already but the status is still pending? Let us recheck it.

signed,please recheck it

The LS_DATE_RE regex expects English month names (Jan, Feb, etc.),
but ls -la output uses numeric months (5, 6, etc.) when the user's
locale sets LC_TIME to a non-English language.

This causes parse_ls_line() to fail on every line, making rtk ls
always return '(empty)' on such systems (e.g. Chinese locale).

Fix by setting LC_TIME=C before executing ls, ensuring the date
format is always 'May  3 12:23' regardless of system locale.

Fixes #(issue number if known)
@lakewaban lakewaban force-pushed the fix/ls-locale-date-parsing branch from 937b01b to 52985bf Compare May 3, 2026 14:05
@KuSh
Copy link
Copy Markdown
Collaborator

KuSh commented May 4, 2026

Hi, thanks for your PR.

This issue is more general than that. The ls command should use LC_ALL=C for any command where we depend on and completely rewrite the output, as there are many issues related to internationalized ls output.

#1338 have just been merged which should fix your problem, if not would you be willing to extend your PR and its associated tests to address these cases as well?

The following issues appear to be related:

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants