Skip to content

CommandError message omits the tmux error text #118

Open

Description

@tony

Summary

LibTmux::CommandError#message is always tmux command failed. The reason tmux gave (duplicate session: work, can't find pane: %99, no current target) is only in error.result.stderr, so an uncaught exception, a log line or a test failure shows no cause. The repository's own writing guide asks for error messages that name "the concrete cause".

Reproduction

  1. Save this program as duplicate.rb:

    require "libtmux"
    
    LibTmux::Server.start do |server|
      server.new_session(name: "work", command: ["/bin/cat"])
      server.new_session(name: "work", command: ["/bin/cat"])
    end
  2. Run it from a checkout of the repository:

    $ ruby -I gems/libtmux/lib duplicate.rb

Expected

The exception message names tmux's reason, as in tmux command failed: duplicate session: work, and the failed command name.

Actual

The trace ends in tmux command failed (LibTmux::CommandError). Rescuing the exception shows the cause is only on the result:

dup session: LibTmux::CommandError: "tmux command failed" stderr="duplicate session: work\n"

A raw command shows the same: server.run(["send-keys", "-t", "%99", "x"]) returns success? false with stderr "can't find pane: %99\n", and the typed wrappers that call execute_typed raise a CommandError whose message omits it.

Environment

Versions
  • libtmux at commit 5dc3761, Ruby 4.0.7, tmux 3.8a, Linux (WSL2)

Evidence

CommandError#initialize defaults the message to "tmux command failed" and keeps the CommandResult apart. Server#execute_typed raises it with no message, so every typed operation reports the same text. The MCP server maps the class to the code command_failed with the fixed message "The operation could not establish its requested result." (application.rb), so an agent sees no reason either.

.github/WRITING.md says: "Error messages name the failed operation, the concrete cause, and a useful next action when one exists."

Proposal

Build the message from the first line of result.stderr and the tmux command name, for example tmux new-session failed: duplicate session: work, and keep the full result on the exception. Cap the stderr excerpt, since stderr is bounded but untrusted text. Add a test that the message contains the stderr text for one typed operation.

Activity

  1. added
    bug
    on Nov 15, 2026
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions