Hmbown/CodeWhale · error

tmux attach failed ( ); command was

Error message

tmux attach failed ({s}); command was: {attach}

What it means

The tmux attach backend spawned the attach command (`tmux -S <socket> attach -t <session>`) and the process ran but exited nonzero (`s.success()` false). The error includes the exit status and the exact command, so the user can retry it manually. This means tmux itself rejected or aborted the attach, not that tmux was missing.

Solutions

  1. Copy the `command was:` portion of the message and run it manually in an interactive terminal to see tmux's real error.
  2. Ensure you run the attach from an interactive TTY (not CI or a piped terminal).
  3. Verify the tmux session still exists (`tmux -S <socket> ls`) and restart the lane if it vanished.
  4. If nested, try `tmux attach -t <session> -d` or detach the outer session first.

Example fix

// before: exits with 'tmux attach failed (exit status 1)'
ci-run: codewhale lane attach lane-1
// after: attach only from an interactive terminal
terminal$ codewhale lane attach lane-1
Defensive patterns

Strategy: try-catch

Validate before calling

await exec(`tmux -S ${socket} has -t ${session}`); // ensure session exists and tmux works before attach

Try / catch

try { attachLane(id); }
catch (e) {
  const m = /command was: (.+)$/.exec(e.message);
  if (m) console.error('retry manually:', m[1]);
}

Prevention

When it happens

Trigger: `tmux attach` exits nonzero — session terminated while attaching, tmux server error, terminal not compatible, or the session died between resolution and attach (race after error 457's check).

Common situations: Attaching from a terminal tmux can't use (non-TTY, nested tmux with odd settings); session killed concurrently; tmux socket permission issues causing server errors; running the command in CI where no TTY exists.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/e047897968cce376. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/lib.rs:976

                );
            };
            if print {
                println!("{attach}");
                return Ok(());
            }
            if let Some(session) = lane.tmux_session.as_deref() {
                let socket = lane
                    .tmux_socket
                    .as_deref()
                    .context("tmux lane is missing its pinned server socket")?;
                let status = Command::new("tmux")
                    .arg("-S")
                    .arg(socket)
                    .args(["attach", "-t", session])
                    .status();
                match status {
                    Ok(s) if s.success() => Ok(()),
                    Ok(s) => bail!("tmux attach failed ({s}); command was: {attach}"),
                    Err(err) => {
                        eprintln!("could not exec tmux: {err}");
                        println!("{attach}");
                        bail!("tmux attach unavailable");
                    }
                }
            } else {
                println!("{attach}");
                Ok(())
            }
        }
        LaneCommand::Logs {
            lane_id,
            follow,
            tail,
        } => {
            let reg = LaneRegistry::open_default()?;
            let lane = reg.load(&lane_id)?;

View on GitHub (pinned to 73e0f67d83)