Skip to content

fix(desktop): make run.sh work in non-English locales#7172

Merged
beastoin merged 1 commit intoBasedHardware:mainfrom
de4nde:worktree-fix-runsh-locale
May 6, 2026
Merged

fix(desktop): make run.sh work in non-English locales#7172
beastoin merged 1 commit intoBasedHardware:mainfrom
de4nde:worktree-fix-runsh-locale

Conversation

@de4nde
Copy link
Copy Markdown
Contributor

@de4nde de4nde commented May 5, 2026

Summary

  • desktop/run.sh fails on first run for users whose shell runs in a non-English locale (e.g. de_DE.UTF-8):
    ./run.sh: line 81: printf: .018953000: invalid number
    
  • Root cause: the step() / substep() timing helpers feed bc output (dot-decimal, e.g. .018953000) into bash's printf "%6.1f", which respects LC_NUMERIC and rejects the dot when the locale expects a comma as decimal separator.
  • Fix: export LC_NUMERIC=C near the top of run.sh so numeric formatting stays POSIX regardless of the user's shell locale. Other locale categories (messages, etc.) are untouched.

Test plan

  • Reproduced the original error locally under LANG=de_DE.UTF-8: printf: .018953000: invalid number
  • With the fix applied, the same printf call prints [ 0.0s] cleanly under LANG=de_DE.UTF-8
  • CI green

🤖 Generated with Claude Code

The timing helpers feed `bc` output (dot-decimal) into bash's `printf %f`,
which fails with "invalid number" when the user's shell runs in a locale
that uses a comma decimal separator (e.g. de_DE.UTF-8).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 5, 2026

Greptile Summary

This PR fixes a one-liner crash in desktop/run.sh that occurs on first run when the user's shell locale uses a comma as the decimal separator (e.g. de_DE.UTF-8). The step()/substep() timing helpers pipe bc output (dot-decimal, e.g. .018953000) into printf "%f", which honors LC_NUMERIC and rejects the dot separator in non-C locales.

  • Adds export LC_NUMERIC=C at the top of run.sh, immediately after set -e, ensuring printf numeric formatting stays POSIX for the duration of the script.
  • Only LC_NUMERIC is overridden — other locale categories (messages, collation, etc.) remain whatever the user has set, so user-facing text is unaffected.

Confidence Score: 5/5

Safe to merge — the change is a single targeted export that restores expected behavior for non-English locale users without side effects on other locale categories.

The fix is exactly one line (export LC_NUMERIC=C) placed at the earliest safe point in the script, before any timing calls that rely on printf numeric formatting. It correctly scopes the override to only LC_NUMERIC, leaving LC_MESSAGES, LC_TIME, and other categories untouched. The root cause analysis matches the fix, and the placement is appropriate.

No files require special attention.

Important Files Changed

Filename Overview
desktop/run.sh Adds export LC_NUMERIC=C to fix printf locale crash on non-English systems; minimal, correct, and well-placed change

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[run.sh starts] --> B[export LC_NUMERIC=C]
    B --> C[SCRIPT_START_TIME = date +%s.%N]
    C --> D{Script step executes}
    D --> E["bc computes elapsed time\n(dot-decimal, e.g. 0.018953)"]
    E --> F["printf '%6.1f' elapsed_time"]
    F --> G["LC_NUMERIC=C → dot accepted\n✅ prints [   0.0s]"]
    H[Without fix] --> I[User's LC_NUMERIC = de_DE.UTF-8]
    I --> J["printf '%6.1f' 0.018953"]
    J --> K["❌ printf: .018953: invalid number"]
Loading

Reviews (1): Last reviewed commit: "fix(desktop): force LC_NUMERIC=C in run...." | Re-trigger Greptile

@beastoin beastoin merged commit 5a66370 into BasedHardware:main May 6, 2026
1 check passed
@beastoin
Copy link
Copy Markdown
Collaborator

beastoin commented May 6, 2026

lgtm @de4nde

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.

2 participants