Skip to content

Server#list_windows and #list_panes raise on a server with no session #119

Open

Description

@tony

Summary

On a server with no session, Server#list_sessions returns [] and Server#snapshot returns an empty snapshot, but Server#list_windows and Server#list_panes raise LibTmux::CommandError. tmux answers no current target because list-windows -a and list-panes -a need a default target when no session exists. A caller that loops over all panes, as the root README's async example does with scope.server.list_panes, crashes instead of seeing an empty list.

Reproduction

  1. Save this program as empty.rb:

    require "libtmux"
    
    LibTmux::Server.start do |server|
      p server.list_sessions
      p server.snapshot.panes.length
      server.list_windows
    end
  2. Run it from a checkout of the repository:

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

Expected

list_windows and list_panes return an empty frozen array, as list_sessions does.

Actual

list_sessions prints [] and snapshot.panes.length prints 0, then list_windows raises:

LibTmux::CommandError: tmux command failed
stderr: "no current target\n"

Server#list_panes raises the same way.

Environment

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

Evidence

Internal::Capture#acquire_rows already knows this: its comment says the window and pane list commands "require a default target" and returns an empty root when list-sessions is empty. Server#list_entities has no such guard, and list_windows and list_panes reach it with -a.

Proposal

Apply the snapshot's rule in list_entities: when the global listing fails and a list-sessions read on the same server is empty, return []; any other failure still raises. Add a test on a started server with no session.

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