Skip to content

Port pages tell readers to save and run shell launchers #319

Open

Description

@tony

Summary

libtmux.org tells readers to save a POSIX shell script and run their program through it on 33 hand-written pages and 97 generated API reference pages. The maintainer's complaint (2026-11-14) is that this reads as an admission that the library cannot do the job from its own language. Each launcher creates a private tmux server, creates fixture sessions with tmux new-session, scrubs TMUX, runs the program, then kills the server and checks for leaks. Eleven of the ports with a launcher page (C#, C++, F#, Go, Julia, PowerShell, Python, Ruby, Rust, Swift, TypeScript) already have a native owned-server API or a ten-line pattern that their own landing-page program uses; the pages should use it. Java, Kotlin and Scala wait on libtmux-java PR #143. Lua and Elixir cannot start a server through the library, and neither can Haskell or OCaml (no launcher page yet, but their landing page and READMEs shell out to tmux); those gaps are tracked in the port repositories.

Expected

Every example and guide program starts and stops its own private server in the port's language, with the port's API. No page shows run.sh, run-mcp.sh, unset TMUX, mktemp or the tmux CLI as setup for a library example. Console blocks keep only the install and run commands.

Use these per port (all exist on master unless noted):

  • Ruby: LibTmux::Server.start { |server| ... }.
  • Julia: LibTmux.with_server / open_server(; tmux, env, timeout, cancel).
  • Erlang: tmux_server:with_owned/2.
  • C#, F#: Server.CreateOwnedAsync / Server.createOwned, which the programs on these pages already call.
  • Rust: Server::builder().socket_path(..).config_file("/dev/null"), new_session, kill(), as the landing program does.
  • Go: tmux.NewServer(tmux.ServerOptions{SocketPath, ConfigFile: os.DevNull}), NewSession, deferred Kill, as examples/quickstart/main.go does.
  • TypeScript: new Server({ socketPath, configFile: "/dev/null" }), newSession, kill() in finally.
  • Python: libtmux.Server(socket_path=..., config_file="/dev/null"), new_session, kill().
  • Swift: Server(socketName:configurationFile:) and killServer().
  • C++: libtmux::Server::startable_at_socket_path and kill() (the C++ API pages currently use libtmux::test::ScopedTmuxServer).
  • PowerShell: New-TmuxServer -SocketName -ConfigurationFile /dev/null, New-TmuxSession, Remove-TmuxSession.
  • Java, Kotlin, Scala, Clojure: Server.start, withPrivateServer, Server.start() / Server.start[F], libtmux.core/start! after libtmux-java PR Frame MCP and workspace companions as concept examples #143 merges. Re-pin the java docs revision, then delete the launcher branches in jvm-examples.ts and clojure-examples.ts and rewrite the Kotlin and Scala concept pages and the two MCP guides.
  • Lua, Elixir, Haskell, OCaml: after the port adds the API named in its issue.

For "Attaching to tmux" the program can start the owned server, create work, then connect a second handle to the same socket; that keeps the "connect to an existing server" lesson without a script.

Drop the ENV/BASH_ENV/SHELL lines: the programs pass explicit pane commands, and -L/-S override TMUX. If a pane environment is needed, set it through the library's session environment option.

Actual

Generators that print a port repository's launcher verbatim (data feed: examples/api/ manifest in the port repo):

  • Clojure: clojure-examples.ts L35-38 and L70-84 prints "Save this file as run.sh. The launcher creates and stops a private server, including after program failure, and reports leaked servers as errors." and sh run.sh clojure ... on 33 reference pages, for example /en/clojure/latest/reference/libtmux-core-open/.
  • Java, Kotlin, Scala: jvm-examples.ts L27 and L99-136 prints run.sh as a fourth setup file and sh run.sh build/install/api-example/bin/api-example on 13 + 14 + 26 reference pages, for example /en/java/latest/reference/io-github-libtmux-server-server/. The generator already branches on "a revision before libtmux-java#142".
  • Lua: lua-examples.ts L26 and L59-72 requires manifest.setup.launcher === 'examples/api/run.sh', so a launcher-less Lua revision fails the build. 11 reference pages.
  • Tests that pin the launcher: packages/api-model/test/{jvm-examples,clojure,lua-examples}.test.ts, site/test/{jvm-api-examples,api-example-verification,wrapper-libraries}.test.ts.

Hand-written pages under site/src/content/docs/ports/ with a sh title="run.sh" block (copy of one template; the page URL is https://libtmux.org/en/<port>/latest/<path without .md>/):

Landing page data, site/src/data/home-examples.json:

  • L24, 65, 97, 133, 179, 215, 501, 532, 563, 593, 786 (Python, Ruby, Lua, TypeScript, Rust, Go, Swift, PowerShell, Julia, Elixir, Lisp): the same two-line unset/export preamble before the run command.
  • L390 and L430 (C#, F#): export TMUX_TMPDIR=/tmp/libtmux-dotnet-dev, mkdir -p, unset TMUX TMUX_PANE.
  • L681 (Haskell): a shell subshell with mktemp -d, trap ... kill-server, env -u TMUX -u TMUX_PANE tmux -S ... new-session -d, link-window, then cabal run.
  • L828 (Erlang): env -u TMUX -u TMUX_PANE erl ....
  • L91 and L101-103 (Lua program text): the program spawns tmux -S sock -f /dev/null start-server ; set-option -s exit-empty off and kill-server with uv.spawn.
  • L588 and L598-600 (Elixir program text): System.cmd(tmux, ["-S", socket, "-f", "/dev/null" | create]).

Port README or guide files ingested by site/src/data/port-guides/*.json that carry shell setup at their pinned revision: OCaml (docs/recovery.md, docs/streaming.md, docs/workspaces.md, docs/workspace-recovery.md), Lua (README.md at pin 0395620d3), Ruby (README.md, gems/libtmux/README.md, gems/libtmux-mcp/README.md, gems/libtmux-workspace/README.md), Lisp (tools/lisp.sh, examples/worker.sh). Those are fixed in each port repository, then re-pinned.

Proposal

Tracked in the port repositories, not here: Lua Runtime:start_server (new issue), Elixir Server.start/stop (libtmux-elixir #82), Haskell startServer plus newSession/linkWindow/killServer (libtmux-haskell #34), OCaml config file on bootstrap and kill-server (libtmux-ocaml #11), JVM Server.start (libtmux-java #142, PR #143).

References

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions