Repository navigation
Description
Summary
A Server() built without socket_name or socket_path passes neither -L nor -S, so the tmux client uses the socket named in $TMUX. Inside a pane, or in any process that inherited a pane's environment, libtmux then talks to that server, not the default one, and kill_session() and kill_server() act there. tmux_cmd has no env=, so a caller cannot strip TMUX for the tmux client without changing os.environ.
Reproduction
- Start a private server, point
$TMUXat its socket, and list sessions through a defaultServer():
import os, subprocess, libtmux
priv = libtmux.Server(socket_name="tmuxenv", config_file="/dev/null")
priv.new_session("inherited-target", window_command="sh")
sock = subprocess.run(["tmux", "-L", "tmuxenv", "display-message", "-p", "#{socket_path}"],
capture_output=True, text=True).stdout.strip()
os.environ["TMUX"] = f"{sock},1,0"
print(sorted(s.name for s in libtmux.Server().sessions))
priv.kill()Expected
libtmux.Server() addresses the default server, or documents that it follows $TMUX.
Actual
['inherited-target']: the default-looking Server() lists the private server's sessions.
Environment
- libtmux:
masterat886b1cd(v0.62.0 plus 114 commits) - tmux: 3.8 (system build reports 3.8a)
- Python: run with
uv run --frozenfrom the libtmux checkout - OS: Linux (WSL2), private
-Lsocket,-f /dev/null
Evidence
libtmux.Server() socket_name/socket_path: None None
sessions seen by libtmux.Server(): ['inherited-target']
follows inherited TMUX: True
References
- Socket flags are added only when set:
src/libtmux/server.py#L395-L398; the client process inherits the caller's environment:src/libtmux/common.py#L331 - Microsoft's amplifier-app-cli installs a
tmuxshim that refuses calls without-L/-Safter this "destroyed 73 live sessions on 2026-08-08 and 81 on 08-12" (launch_lane.sh#L131) - OpenHands' training skill unsets
TMUX"solibtmuxinside OpenHands does not attach to the launcher's tmux server" (SKILL.md#L88) - Hermes strips every
TMUX*variable (_classic.py#L234); NVIDIA's supervisor resets the environment (supervisor.py#L1114); oh-my-opencode-slim refuses socket-less calls (index.ts#L246) - Related: Expose tmux spawn provenance: a typed libtmux.env (TmuxEnv, spawn_session, is_inside_tmux) #712 (spawn provenance),
Serverliveness, list error handling, andEnvironmentMixinerrors #704 (self-location)
Keep inventory and creation on the same socket
On 6c92651, a bare Server() inside tmux listed sessions on the inherited socket. Detached new_session() through that same object created the worker on the fixture's private default socket. During dispatch, a second thread could also observe that TMUX had disappeared from the parent environment. Restoring the variable after the subprocess returns leaves that interval visible. Parent environment mutation · Restoration
Give two private servers different sentinel sessions. Compare the socket path with the native client, then verify inventory, creation and the returned session all address that socket. Session IDs such as $0 can occur on both servers. Test explicit -L and -S selectors as controls. At the dispatch boundary, synchronize a second thread that reads os.environ and verify the original value throughout. Local tests exercised this on tmux 3.3a and 3.8. #882 covers passing a child environment to the launch layer.
Activity
tony commentedon Nov 21, 2026
Cross-port socket-selection contract is tracked in libtmux/central#17 and libtmux/central#16 (ADR 0004);
tmux_cmd(src/libtmux/common.pylines 331–338) also needs an explicitenvparameter so callers andServer()can scrubTMUXwithout mutatingos.environ.tony commentedon Nov 24, 2026
#923 (
Server.connect_or_start()) depends on this decision: which server a bareServer()ensures when$TMUXis inherited. #771 addsLIBTMUX_SOCKET_PATH/LIBTMUX_SOCKET_NAMEdefaults that would settle it implicitly. Ordering is in #925.tony commentedon Dec 4, 2026
#954 exercises nested and explicit sockets, per-request environment changes, and retained session, window, and pane handles. Private servers with overlapping IDs make misrouting visible. Tests distinguish the default command runner from an injected control client already attached to a particular daemon.
Server(feat[socket]): Target default server on bare Server()
Server(feat[socket]): Target default server on bare Server()
CHANGES(docs): Route bare Server() to default
Server(feat[socket]): Target default server on bare Server()
CHANGES(docs): Route bare Server() to default
Server(feat[socket]): Target default server on bare Server()
CHANGES(docs): Route bare Server() to default
Server(feat[socket]): Target default server on bare Server()
CHANGES(docs): Route bare Server() to default