Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,35 @@
with:
token: ${{ secrets.CODECOV_TOKEN }}

unsupported-tmux:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-latest
env:
UV_EXCLUDE_NEWER: P3D
strategy:
matrix:
tmux-version: ['3.2a', '3.3']
steps:
- uses: actions/checkout@v7
- uses: astral-sh/setup-uv@v10.2.0
- run: uv python install 3.14
- run: uv sync --locked --all-extras --dev
- name: Build unsupported tmux
run: |
sudo apt-get update
sudo apt-get install -y tmux libevent-dev libncurses-dev bison
git clone --depth 1 --branch '${{ matrix.tmux-version }}' https://github.com/tmux/tmux.git "$RUNNER_TEMP/old-tmux"
cd "$RUNNER_TEMP/old-tmux"
sh autogen.sh
./configure --prefix="$RUNNER_TEMP/old-tmux-install"
make -j2
make install
- name: Refuse before imports and callbacks
env:
TMUXP_TEST_OLD_TMUX: ${{ runner.temp }}/old-tmux-install/bin/tmux
run: uv run --locked pytest tests/test_tmux_versions.py -k unsupported --reruns=0

release:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
Expand Down
29 changes: 29 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,35 @@ raised `KeyError(0)` in the IPython parser. CI now checks the CLI, documentation
extensions, tests and build helpers with ty.
([#1120](https://github.com/tmux-python/tmuxp/pull/1120))

### Breaking changes

#### The tmux 3.3a minimum is checked against the server (#1092)

Loading, freezing, and `tmuxp shell` now check the selected tmux daemon (or
cold executable when no server is running) for `tmux>=3.3a`, including its
patch letter, before workspace imports, plugins, callbacks, or scripts. A newer
`tmux` client executable no longer authorizes an older running daemon.

Save your sessions before restarting an older daemon, or target a fresh socket:

```console
$ tmuxp load -L new-socket workspace.yaml
```

Help, version information, diagnostics, workspace listing, and workspace
conversion remain available without tmux. See {doc}`project/compatibility` for
installation requirements.

### Dependencies

#### Coordinated `libtmux` 0.71 version check (#1092)

Requires libtmux 0.71 or newer, whose version check covers the connected daemon
before every command (`uv.lock` pins the development revision while
`pyproject.toml` stays on `libtmux~=0.70.0` until libtmux 0.71.0 is released).
tmuxp checks a daemon once per workspace build, and a libtmux without that
module is refused before custom code runs.

## tmuxp 1.84.0 (2026-11-28)

tmuxp 1.84.0 updates libtmux to 0.70.0. `tmuxp shell` no longer writes
Expand Down
11 changes: 11 additions & 0 deletions MIGRATION
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ _Notes on the upcoming release will be added here_

<!-- Maintainers, insert changes / features for the next release here -->

### tmux 3.3a minimum

Upgrade tmux to 3.3a or newer before loading or freezing workspaces or opening
`tmuxp shell`. The minimum includes its patch letter. Save your sessions
before restarting an older daemon; updating the client alone does not
upgrade a running server.

This release requires libtmux 0.71 or newer. Until libtmux 0.71 is released,
install a checkout with `uv sync --locked`.
Help, diagnostics, and configuration conversion do not require tmux.

## tmuxp 1.18.0 (2022-10-30)

**Restructuring** (#840)
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Session manager for tmux. Save and load your tmux sessions through
declarative workspace files. Powered by
[libtmux](https://github.com/tmux-python/libtmux).

Requires tmux **3.3a or newer** and Python **3.11 or newer**. The selected
daemon must meet the minimum even when a newer tmux client is installed.

[![Python Package](https://img.shields.io/pypi/v/tmuxp.svg)](https://pypi.org/project/tmuxp/)
[![Docs](https://github.com/tmux-python/tmuxp/workflows/docs/badge.svg)](https://tmuxp.git-pull.com/)
[![Build status](https://github.com/tmux-python/tmuxp/workflows/tests/badge.svg)](https://github.com/tmux-python/tmuxp/actions?query=workflow%3A%22tests%22)
Expand Down
8 changes: 7 additions & 1 deletion docs/cli/debug-info.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

# tmuxp debug-info

Collect and display system information useful for debugging tmuxp issues and submitting bug reports.
Collect and display system information useful for debugging tmuxp issues and
submitting bug reports. The command remains available when tmux is missing
or the selected daemon is below the minimum. It does not start a server.

JSON output keeps unavailable state lists empty and records the reason in
`tmux_errors`, keyed by the failed query. `tmux_version` describes the
executable, while version errors in `tmux_errors` describe the daemon.

## Command

Expand Down
50 changes: 50 additions & 0 deletions docs/project/compatibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# tmux compatibility

tmuxp requires tmux 3.3a or newer. The patch letter matters: tmux 3.3 is below
the minimum. Ordinary workspace creation, pane splitting, input, capture,
layout, and freezing remain available on tmux 3.3a.

The selected daemon determines compatibility when a socket is already
running. A cold socket uses the selected executable's version. Installing a
new executable does not upgrade an existing daemon. Save your sessions
before restarting an older daemon, or use a new socket name.

Workspace loading checks the selected endpoint before importing a custom
builder or plugin. The classic builder checks a supplied session or window's
server before callbacks and scripts. `tmuxp shell` checks before executing
`-c`, importing a shell, or loading `PYTHONSTARTUP`. Later native operations
carry libtmux's command version check. They refuse a replacement daemon whose
version differs from the version checked for that command.

`--help`, `--version`, `debug-info`, and workspace conversion remain available
without a running server or an installed tmux executable.

## Installing this checkout

This branch requires libtmux 0.71 or newer, the first release that carries
the daemon version check. Until that release exists, `uv.lock` pins an exact
development revision while `pyproject.toml` stays on `libtmux~=0.70.0`.
Install the checkout with its lockfile:

```console
$ uv sync --locked
```

A plain package install does not apply uv's source selection and picks the
released libtmux. If the installed libtmux lacks the version check, tmuxp
refuses to load, freeze, or open a shell. Release libtmux 0.71 first, then
bump `pyproject.toml` to `libtmux~=0.71.0`, drop the source pin, and merge
this change.

## Workspace scripts and custom code

tmuxp sends `shell_command` text to a pane's shell. That shell executes the
operator's code. `before_script` runs a separate program, and plugins and
custom builders execute Python code. The compatibility check does not parse
or constrain those programs, their own tmux clients, or commands embedded
inside scripts. Redefining libtmux's built-in tmux commands through
`command-alias` also falls outside the managed command guarantee.

Readiness polling and configured `sleep_before`/`sleep_after` values remain
part of workspace behavior. Raising the minimum does not make shell startup
or asynchronous terminal output immediate.
1 change: 1 addition & 0 deletions docs/project/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ Release checklist and version policy.

contributing
code-style
compatibility
releasing
```
2 changes: 1 addition & 1 deletion docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ takes you from nothing to a running session.

## Installation

Ensure you have at least tmux **>= 3.3a** and python **>= 3.11**.
Ensure you have at least tmux **>= 3.3a** and Python **>= 3.11**.

```console
$ pip install --user tmuxp
Expand Down
5 changes: 4 additions & 1 deletion docs/topics/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ Ensure tmux is installed:
$ tmux -V
```

Minimum required version: tmux 3.3a.
Minimum required version: tmux 3.3a, including the patch letter. A running
daemon keeps its old version after you upgrade the tmux executable. Save
your work and restart that daemon, or select a new socket with `tmuxp load
-L new-socket workspace.yaml`. See {doc}`../project/compatibility`.

## Configuration errors

Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ exclude = [
"src/tmuxp/CLAUDE.md",
]

[tool.uv.sources]
libtmux = { git = "https://github.com/tmux-python/libtmux.git", rev = "a3fdff7ca174739af0e058ea3458be9f0f27e3ef" }

[tool.uv.exclude-newer-package]
ty = false
# git-pull packages release in lockstep with their workspaces, so a
Expand Down
27 changes: 16 additions & 11 deletions src/tmuxp/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
import typing as t

from libtmux.__about__ import __version__ as libtmux_version
from libtmux.common import has_minimum_version
from libtmux.exc import TmuxCommandNotFound, VersionTooLow

from tmuxp import exc
from tmuxp.__about__ import __version__
from tmuxp.log import setup_logger

from ._colors import build_description
from ._colors import Colors, build_description, get_color_mode
from ._formatter import TmuxpHelpFormatter, create_themed_formatter
from .convert import CONVERT_DESCRIPTION, command_convert, create_convert_subparser
from .debug_info import (
Expand Down Expand Up @@ -285,20 +284,26 @@ def cli(_args: list[str] | None = None) -> None:
See detailed documentation and examples at:
http://tmuxp.git-pull.com/
"""
try:
has_minimum_version()
except TmuxCommandNotFound:
tmuxp_echo("tmux not found. tmuxp requires you install tmux first.")
sys.exit()
except (exc.TmuxpException, VersionTooLow) as e:
tmuxp_echo(str(e))
sys.exit()

parser = create_parser()
args = parser.parse_args(_args, namespace=ns)

setup_logger(level=args.log_level.upper())

try:
_dispatch(args, parser)
except (VersionTooLow, TmuxCommandNotFound, exc.LibtmuxCompatibilityError) as error:
colors = Colors(get_color_mode(args.color))
detail = (
"tmux executable not found; install tmux 3.3a or newer"
if isinstance(error, TmuxCommandNotFound)
else str(error)
)
tmuxp_echo(colors.error("[Tmux Error]") + f" {detail}")
sys.exit(1)


def _dispatch(args: CLINamespace, parser: argparse.ArgumentParser) -> None:
"""Run the selected subcommand after argument parsing."""
if args.subparser_name is None:
parser.print_help()
return
Expand Down
70 changes: 55 additions & 15 deletions src/tmuxp/cli/debug_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
import typing as t

from libtmux.__about__ import __version__ as libtmux_version
from libtmux.common import get_version_str, tmux_cmd
from libtmux.common import tmux_cmd
from libtmux.exc import LibTmuxException

from tmuxp.__about__ import __version__
from tmuxp._internal.private_path import PrivatePath, collapse_home_in_string
Expand Down Expand Up @@ -98,6 +99,17 @@ def _private(path: pathlib.Path | str | None) -> str:
return str(PrivatePath(path))


def _executable_version(binary: str) -> str:
"""Return the tmux executable's version verbatim, keeping letter suffixes."""
response = tmux_cmd("-V", tmux_bin=binary)
report = response.stdout[0] if response.stdout else ""
if response.returncode or not report:
detail = "\n".join(response.stderr).strip()
msg = detail or "tmux version unavailable"
raise LibTmuxException(msg)
return report.removeprefix("tmux ").strip()


def _collect_debug_info() -> dict[str, t.Any]:
"""Collect debug information as a structured dictionary.

Expand All @@ -116,12 +128,40 @@ def _collect_debug_info() -> dict[str, t.Any]:
>>> 'tmux_version' in data
True
"""
# Collect tmux command outputs
sessions_resp = tmux_cmd("list-sessions")
windows_resp = tmux_cmd("list-windows")
panes_resp = tmux_cmd("list-panes")
global_opts_resp = tmux_cmd("show-options", "-g")
window_opts_resp = tmux_cmd("show-window-options", "-g")
binary = shutil.which("tmux")
errors: dict[str, str] = {}
tmux_version = "not found"
if binary is not None:
try:
tmux_version = _executable_version(binary)
except LibTmuxException as error:
tmux_version = "unavailable"
errors["version"] = collapse_home_in_string(
str(error) or "tmux version unavailable"
)

def collect(name: str, *command: str) -> list[str]:
if binary is None:
errors[name] = "tmux executable not found"
return []
try:
response = tmux_cmd("-N", *command, tmux_bin=binary)
except LibTmuxException as error:
errors[name] = collapse_home_in_string(
str(error) or "tmux executable not found"
)
return []
if response.returncode:
errors[name] = collapse_home_in_string("\n".join(response.stderr))
return response.stdout

tmux = {
"sessions": collect("sessions", "list-sessions"),
"windows": collect("windows", "list-windows"),
"panes": collect("panes", "list-panes"),
"global_options": collect("global_options", "show-options", "-g"),
"window_options": collect("window_options", "show-window-options", "-g"),
}

return {
"environment": {
Expand All @@ -132,19 +172,14 @@ def _collect_debug_info() -> dict[str, t.Any]:
},
"python_version": " ".join(sys.version.split("\n")),
"system_path": collapse_home_in_string(os.environ.get("PATH", "")),
"tmux_version": get_version_str(),
"tmux_version": tmux_version,
"libtmux_version": libtmux_version,
"tmuxp_version": __version__,
"tmux_path": _private(shutil.which("tmux")),
"tmuxp_path": _private(tmuxp_path),
"shell": _private(os.environ.get("SHELL", "")),
"tmux": {
"sessions": sessions_resp.stdout,
"windows": windows_resp.stdout,
"panes": panes_resp.stdout,
"global_options": global_opts_resp.stdout,
"window_options": window_opts_resp.stdout,
},
"tmux": tmux,
"tmux_errors": errors,
}


Expand Down Expand Up @@ -239,6 +274,11 @@ def format_tmux_section(lines: list[str]) -> str:
+ format_tmux_section(tmux_data["window_options"]),
]

if errors := data.get("tmux_errors"):
output.append(
f"{colors.format_label('tmux errors')}:\n"
+ "\n".join(f"\t{name}: {error}" for name, error in errors.items())
)
return "\n".join(output)


Expand Down
2 changes: 2 additions & 0 deletions src/tmuxp/cli/freeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ def command_freeze(

server = Server(socket_name=args.socket_name, socket_path=args.socket_path)

util._require_tmux(server)

try:
if args.session_name:
session = server.sessions.get(session_name=args.session_name, default=None)
Expand Down
3 changes: 1 addition & 2 deletions src/tmuxp/cli/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import logging
import os
import pathlib
import shutil
import sys
import typing as t

Expand Down Expand Up @@ -600,7 +599,7 @@ def load_workspace(
colors=colors,
)

shutil.which("tmux") # raise exception if tmux not found
util._require_tmux(t)

# Builder resolution + creation — outside spinner so plugin prompts are safe.
# Trusted import roots (absent config -> [] -> a no-op sandbox) stay on
Expand Down
1 change: 1 addition & 0 deletions src/tmuxp/cli/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def command_shell(

server = Server(socket_name=args.socket_name, socket_path=args.socket_path)

util._require_tmux(server)
server.raise_if_dead()

current_pane = util.get_current_pane(server=server)
Expand Down
Loading