Skip to content

Start the tmux server with a UTF-8 locale - #65

Merged
ryanclouser merged 1 commit into
ProjectHax:masterfrom
freddysae0:fix/tmux-server-utf8-locale
Oct 6, 2026
Merged

ryanclouser merged 1 commit into
ProjectHax:masterfrom
freddysae0:fix/tmux-server-utf8-locale

Conversation

@freddysae0

Copy link
Copy Markdown
Contributor

Opened by Claude (Claude Code), the AI assistant of @freddysae0, on their behalf. Freddy asked me to pass along that they're really enjoying muxel, and thanks for merging #63 so quickly!

Fixes #64

Problem

On macOS, text copied from an agent running in a tmux-backed pane loses every non-ASCII character to mojibake: aprobación → aprobaci√≥n, ▎ → ‚ñé. Agents copy through pbcopy, and pbcopy decodes its input as Mac Roman when the process has no locale.

The process has no locale because of how the shared tmux server is started. ensure_tmux_server() runs it with a plain Command, so it inherits muxel's GUI environment, where launchd sets no LANG/LC_*. Every program in a session is a child of that server. The LANG fallback that ensure_utf8_locale adds only reaches each pane's tmux client, and tmux doesn't forward LANG to new sessions because it is not in the default update-environment.

Fix

Give the tmux start-server command the same fallback the PTY path already uses: needs_utf8_locale → LANG=FALLBACK_UTF8_LOCALE. Like ensure_utf8_locale, it only fills a gap. A locale the user has actually set is never touched.

One file changed (crates/muxel/src/integrations.rs).

Verification

  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings and cargo test --workspace all pass.

  • I ran a throwaway test, not included here, that clears LANG/LC_ALL/LC_CTYPE and calls the real ensure_tmux_server() on an isolated TMUX_TMPDIR. It then opens a session the way a pane does (tmux -u new-session, with LANG set on the client) and records what the program inside sees:

    Build Program inside the session sees
    master (006b8b2) LANG= (nothing)
    this PR LANG=en_US.UTF-8
  • pbcopy on its own, outside muxel, reproduces the reporter's exact output without a locale and correct text with one (see macOS: tmux server starts without a locale, so non-ASCII text copied from agent panes is mojibake (á → √°) #64).

Note for existing users

The tmux server outlives muxel, so anyone who already has a server running keeps its empty environment until that server restarts (tmux kill-server, or a reboot). New servers get the locale from the start.

🤖 Generated with Claude Code

ensure_tmux_server spawned `tmux start-server` with muxel's GUI
environment, which on macOS carries no LANG/LC_*. Every program in a
session is a child of that server, so agents ran with no locale and
anything locale-dependent fell back to ASCII. The visible symptom: text
copied through pbcopy decodes as Mac Roman, turning "aprobación" into
"aprobación".

Default LANG on the server command the same way ensure_utf8_locale
already does for pane clients: only when no locale is declared at all.

Fixes ProjectHax#64

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@freddysae0

Copy link
Copy Markdown
Contributor Author

Hi there, before merging please consider if this is the best solution, the issue is totally true, as a spanish speaker I was having the problem described in the PR.

@ryanclouser
ryanclouser merged commit 856068d into ProjectHax:master Oct 6, 2026
5 checks passed
@ryanclouser

Copy link
Copy Markdown
Contributor

Thanks, merged! And glad you're enjoying muxel.

On whether this is the best fix: I think so. Programs in a session inherit the tmux server's environment, not the client's, so the server is the right place for the fallback. The alternatives were worse: new-session -e LANG=… needs tmux 3.2+, and set-environment -g or adding LANG to update-environment would change a server people may share with their own tmux. Filling the gap only when no locale is set matches what panes already do. As you noted, an already-running server needs a restart to pick it up.

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.

macOS: tmux server starts without a locale, so non-ASCII text copied from agent panes is mojibake (á → √°)

2 participants