resolve_socket_path
Resolve the socket path tmux uses for socket_name.
Source and package
- Qualified name
-
libtmux._internal .env. resolve _socket _path - Module
- libtmux._internal.env
- Package
- libtmux
- Source
- src/libtmux/_internal/env.py
-
Description
tmux keeps its sockets in
tmux-<euid>underTMUX_TMPDIR, falling back to/tmpwhen that is unset or empty.TMPDIRis deliberately not consulted -- tmux does not consult it either. The socket directory is resolved through symlinks, as tmux resolves it before binding, so a symlinkedTMUX_TMPDIRyields the path tmux itself reports.A
TMUX_TMPDIRtmux cannot resolve falls back the same way. tmux takes the first ofTMUX_TMPDIRand/tmpthat resolves, so a path that is not there -- or a broken symlink -- is never the one it binds, and measuring it would refuse a server tmux reaches without difficulty. A directory it resolves but cannot createtmux-<euid>under is an error from tmux, not a fallback.The path is computed, not observed: it says where tmux would put the socket, not that a daemon is listening there. Code holding a live
Servershould ask tmux instead, with the#{socket_path}format.- Parameters
-
-
socket_name(str | None) – Socket name, as passed to tmux's-L. Defaults to tmux's own default,"default".Default
None -
env(t.Mapping [str, str] | None) – Environment to read. Defaults toos.environ.Default
None
-
- Returns
-
pathlib.PathPath tmux resolves the socket to.
Examples
>>> from libtmux._internal.env import resolve_socket_path>>> resolve_socket_path(env={})PosixPath('/tmp/tmux-.../default')>>> resolve_socket_path("mysocket", env={"TMUX_TMPDIR": "/usr"})PosixPath('/usr/tmux-.../mysocket')TMPDIRis not a socket directory, so it changes nothing:>>> resolve_socket_path(env={"TMPDIR": "/var/folders/xy"})PosixPath('/tmp/tmux-.../default')Nor does a
TMUX_TMPDIRtmux cannot use, however long it is:>>> resolve_socket_path(env={"TMUX_TMPDIR": "/nonexistent-" + "d" * 200})PosixPath('/tmp/tmux-.../default')
Recorded calls
source callsThe Python reference records declarations, not calls, so this page shows no callers or callees. That is a limit of the extracted data, not a statement that nothing calls libtmux._internal.env.resolve_socket_path.