Skip to content

binary must be an absolute path, so every program hard-codes /usr/bin/tmux #109

Done

Description

@tony

Summary

Runtime:start_server and Runtime:connect require binary to be an absolute path and never look tmux up on PATH, so every program must find its own tmux, and 18 example programs and the README hard-code /usr/bin/tmux. On a machine whose tmux lives elsewhere, such as Homebrew, Nix or a source build in /usr/local, the first program fails until the reader learns about TMUX_BIN.

Motivation

An adopter writes runtime:start_server({ binary = ... }) and must answer "where is tmux" in their own code first. The README's install notes cover macOS (Xcode tools and cmake for luv), where Homebrew installs tmux under /opt/homebrew/bin, while the default every program carries is /usr/bin/tmux. The environment override is documented only in a comment inside each program.

Evidence

lua/libtmux/_internal/server.lua lines 641-644 rejects a relative binary with start needs an absolute tmux executable path, and ConnectOptions.binary is documented as Absolute tmux executable path (line 1259). docs/runtime.md line 31 lists binary as required.

Every program begins with the same two lines, shown here from examples/api/new_session.lua lines 10-11:

-- tmux is /usr/bin/tmux unless TMUX_BIN names another absolute path.
local binary = os.getenv("TMUX_BIN") or "/usr/bin/tmux"

rg -l '/usr/bin/tmux' examples --glob '*.lua' lists 18 programs, and README.md repeats the default on 17 lines.

A search of open and closed issues for binary, PATH and absolute finds only the closed #103, which added start_server and kept the required path.

Proposal

Make binary optional: when it is absent, resolve tmux from PATH once, check that the result is an executable regular file, and use the absolute path from then on, so the existing identity checks and the rejection of relative values stay. Expose the same lookup as a public function (for example libtmux.find_tmux()) for callers who want to show or log the path. Then delete the TMUX_BIN pair from the 18 examples and the README copies, and keep one sentence under start_server saying how to name a specific binary. Add a unit test with a temporary PATH that holds a fake tmux, and one that asserts a relative binary is still refused.

Executable lookup on PR 27

On the tested head of PR 27 (65a471fc7), Runtime:connect successfully selected the client from client_env.PATH when binary was omitted. An explicit binary = "tmux" was refused with invalid_endpoint. Three malformed endpoint inputs also reported operation connect and effect not_sent. The valid command and snapshot passed on native tmux 3.7c.

A separate caller need remains when an example must invoke the same tmux inside a pane to signal completion. The capture, input and quick-start examples all do that. A local public Runtime:find_tmux():await() candidate gave those callers the selected executable. Its controls covered a changed PATH, a changed working directory and cancellation. Keep that API distinction when reviewing PR 27.

PATH discovery for owned-server examples

The current PATH change lets examples start tmux without an absolute binary argument. The vote-counter example ran with tmux selected from PATH and with an explicit TMUX_BIN. The tested combined release also uses PATH for the complete-line example when TMUX_BIN is unset. This example follows the discovery change in the release order. PATH discovery · Complete-line example

Activity

  1. added
    p2
    enhancement
    area:core
    topic:api
    topic:cli
    lua
    on Dec 3, 2026
  2. tony commented on Dec 5, 2026

    @tony
    ContributorAuthor

    There is now a standalone PR for the PATH lookup originally demonstrated on the lifecycle branch. It keeps the explicit binary override and gives the vote and window programs the same selection rule.

    Pull request #179.

    The original vote branch failed with start needs an absolute tmux executable path when tmux was on PATH and TMUX_BIN was unset. LuaLS also flagged the optional executable. The published vote branch now includes the library’s PATH lookup from #179. The same command passed on tmux 3.7 and 3.8, and LuaLS passed on both tested Lua toolchains. Original hosted diagnostic · Working vote demo.

    The capability demo and the original pane-job exit demo also picked /usr/bin/tmux even when tmux 3.3a was first on PATH. Both now use the executable selected by the caller in the local rebase checks. The navigation, move-window and layout programs already used it, so their guide only needed the obsolete setup line removed. Each correction stays with the PR that introduces the example. Capability report · Pane-job exit · Window examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:coreenhancementluap2topic:apitopic:cli

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions