tmux: prefer a newer tmux binary in the bin/tmux wrapper when available#76
Merged
Conversation
The wrapper hardcoded /usr/bin/tmux, which on many hosts is an ancient build (e.g. 2.6) that lacks the escape-sequence proxying modern full-screen TUIs rely on (synchronized output, RGB negotiation, DCS passthrough), so such TUIs render with intermittent garbling/tearing. Pick the highest-version tmux among the system binary and common Homebrew locations (recursion-safe: never re-invoke the wrapper itself), falling back to /usr/bin/tmux when nothing newer is installed. Add a SANDBOX_TMUX_BIN escape hatch to pin a specific binary. After 'brew install tmux' outside the sandbox, the wrapper uses it automatically — no further config.
Owner
Author
|
Reviewed adversarially and re-verified the selection logic empirically (exec-override harness sourcing the wrapper, stub tmux binaries):
Security posture: no weakening — the wrapper execs a user-reachable binary inside the sandbox, which any sandboxed process could do anyway; Two additions pushed to the branch (merge of
Two minor notes, non-blocking:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On hosts whose system tmux is an ancient build — e.g. tmux 2.6 (2017), still the default on several enterprise Linux baselines — Claude Code (and other modern full-screen TUIs) render with intermittent garbling/tearing inside the sandbox. The dominant cause is synchronized output (DCS
?2026h/l), which batches a full-frame redraw so partial paints never show; tmux only learned to proxy it correctly in 3.2–3.3. RGB negotiation (terminal-features, 3.2) and DCS passthrough (allow-passthrough, 3.3) are in the same boat. No 2.6-era config fully fixes the rendering — the durable fix is to run a newer tmux.But
bin/tmuxhardcodes/usr/bin/tmux, so even when the user installs a modern tmux (e.g.brew install tmux→ 3.5+), the sandbox keeps using the old one.Change
bin/tmuxnow picks the highest-version tmux among the system binary and the common Homebrew locations ($HOMEBREW_PREFIX/bin,~/.linuxbrew/bin,/home/linuxbrew/.linuxbrew/bin,/opt/homebrew/bin,/usr/local/bin), falling back to/usr/bin/tmuxwhen nothing newer is present. Details:tmuxonPATH, so each candidate isreadlink -f-compared against the wrapper itself and skipped if it resolves to this script.tmux -Vparses to a highermajor*100+minorthan the current best, so an equally-old binary in/usr/local/binnever displaces the system one.SANDBOX_TMUX_BINescape hatch — set it to pin a specific binary regardless of version.After
brew install tmuxoutside the sandbox, the wrapper uses it automatically — no further config.Note on the injected conf
The companion half —
sandbox-tmux.conferroring withinvalid option: allow-passthrough/extended-keys/terminal-featureson tmux < 3.3 — was already fixed in v0.13.0-rc.2 by guarding the version-only options withset -q(verified on tmux 2.6: asource-fileof the guarded conf exits 0 with zero warnings, vs. 4 errors unguarded). This PR is the second, durable half: it makes the wrapper actually run a modern tmux when one is available, fixing the rendering itself rather than just silencing the config warnings. Installs still on 0.13.0-rc.1 will continue to emit those conf warnings until upgraded to ≥ 0.13.0-rc.2.Testing
bash -n bin/tmux— clean.tmux 3.5a: chosen over the 2.6 system binary (305 > 206);SANDBOX_TMUX_BINoverride honored; self-reference skipped./usr/bin/tmux, launches a session cleanly (exit 0, no warnings),prefix C-afrom the conf applied, isolated-Lsocket throughout.escape-time(and the rest of the conf) untouched — no regression to paste-timing behavior.Operator activation