Running inside tmux fails with "sessions should be nested with care, unset $TMUX to force" #1
Labels
No labels
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
backmeupplz/superharness#1
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
Running
superharnessfrom within an existing tmux session (which is the default environment in many Linux setups, including Omarchy) always fails with:Root cause
In
src/tmux/session.rs, theinitfunction unconditionally callstmux attach-sessionto present the session to the user. When$TMUXis already set (i.e. the user is inside a tmux session), tmux refuses to attach because it detects nesting and exits with a non-zero code, which triggersbail!("tmux attach failed").Expected behaviour
superharnessshould work seamlessly whether launched from a bare terminal or from inside an existing tmux session. This is especially important for users whose default terminal environment is tmux (e.g. Omarchy, tmuxinator users, etc.).Fix
When
$TMUXis set, usetmux switch-client -t superharnessinstead oftmux attach-session -t superharness.switch-clientmoves the current tmux client to the target session without nesting, which is exactly what is needed here. Becauseswitch-clientreturns immediately (unlikeattach-sessionwhich blocks until detach), the session-cleanup code must be skipped in this branch so the session is not killed right after switching to it.Workaround
This was fixed in commit
10f7ede(feat/tmux-attach). SuperHarness now detects$TMUXand usesswitch-clientinstead ofattach-sessionwhen already inside a tmux session. Thanks for reporting!