Skip to content

Commit b11c74f

Browse files
committed
docs(CHANGES): Socket paths are measured before tmux sees them
why: A socket path that cannot bind fails as a tmux error naming the path but not the numbers, and a deep pytest `tmp_path` reaches the limit without anyone typing a long path. what: - Record the socket-path measurement under `What's new`, naming where each route is measured and the shorter-directory workaround.
1 parent 574cc14 commit b11c74f

1 file changed

Lines changed: 34 additions & 2 deletions

File tree

CHANGES

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,42 @@ $ uvx --from 'libtmux' --prerelease allow python
4545
_Notes on the upcoming release will go here._
4646
<!-- END PLACEHOLDER - ADD NEW CHANGELOG ENTRIES BELOW THIS LINE -->
4747

48+
### What's new
49+
50+
#### Socket paths are measured before tmux sees them (#730)
51+
52+
A tmux socket is a UNIX domain socket, so its path is capped by `sockaddr_un`
53+
— 107 bytes on Linux, 103 on macOS. {class}`~libtmux.Server` now measures the
54+
path and raises the new {exc}`~libtmux.exc.SocketPathTooLong`, carrying the
55+
byte count, how far over the limit it is, and where the length came from.
56+
tmux reports the overrun as `error connecting to <path> (File name too long)`,
57+
which names the path but not the numbers, nor which variable made it long.
58+
59+
Where the measurement happens follows what tmux actually reads. A
60+
`socket_path` is passed through unchanged as `-S<path>`, so it is measured at
61+
construction, where the caller can still change it. A `socket_name` resolves
62+
against `$TMUX_TMPDIR` — which tmux re-reads when it runs, not when the
63+
{class}`~libtmux.Server` was built — so it is measured on each command
64+
instead. The inherited case is the one that bites: a pytest `tmp_path`, an XDG
65+
runtime dir, a nested worktree, a CI checkout under a long workspace prefix.
66+
The fix is a shorter socket directory: {func}`tempfile.mkdtemp` or a short
67+
`$TMUX_TMPDIR`. See {ref}`socket_path_length` for the pytest case.
68+
69+
Naming a server that way stays free of side effects, so
70+
{meth}`~libtmux.Server.is_alive` keeps answering — an address the kernel
71+
cannot hold is one more way of not being alive — and
72+
{meth}`~libtmux.Server.raise_if_dead` keeps being the way to ask why.
73+
74+
A bare {class}`~libtmux.Server` inside a tmux pane is left alone. tmux prefers
75+
`$TMUX` over `$TMUX_TMPDIR` when no socket is named, so a script running
76+
inside tmux is measured against the socket it will actually use rather than a
77+
directory tmux never consults.
78+
4879
### Fixes
4980

50-
- {class}`~libtmux.Server` now reprs the socket path tmux resolves from
51-
`$TMUX_TMPDIR` instead of a hard-coded `/tmp/tmux-<euid>/default` (#723)
81+
- {class}`~libtmux.Server` now reprs the socket a bare tmux client would use —
82+
`$TMUX` inside a pane, otherwise the path resolved from `$TMUX_TMPDIR`
83+
instead of a hard-coded `/tmp/tmux-<euid>/default` (#727)
5284

5385
### Documentation
5486

0 commit comments

Comments
 (0)