{"record":{"id":"3aa968cafc60f15c","repo":"Hmbown/CodeWhale","slug":"tmux-new-session-failed-with-status","errorCode":null,"errorMessage":"tmux new-session failed with {status}","messagePattern":"tmux new-session failed with (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/lane/src/runtime.rs","lineNumber":783,"sourceCode":"        );\n\n        let mut cmd = tmux_command(&socket);\n        cmd.args([\"new-session\", \"-d\", \"-s\", &session]);\n        if let Some(cwd) = cwd.as_ref() {\n            cmd.arg(\"-c\").arg(cwd);\n        }\n        cmd.arg(shell_cmd);\n        let proposed_record = record.clone();\n        let spawned = std::cell::Cell::new(false);\n        let rolled_back = std::cell::Cell::new(false);\n        match registry.mark_running_if_pending_with(\n            record,\n            || {\n                let status = cmd\n                    .status()\n                    .with_context(|| format!(\"spawn tmux session {session}\"))?;\n                if !status.success() {\n                    bail!(\"tmux new-session failed with {status}\");\n                }\n                spawned.set(true);\n                Ok(())\n            },\n            || {\n                stop_tmux_session(&socket, &session)?;\n                rolled_back.set(true);\n                Ok(())\n            },\n        ) {\n            Ok(true) => {}\n            Ok(false) => {\n                if let Some(path) = environment_path.as_deref() {\n                    remove_file_if_present(path)?;\n                }\n                let mut stopped_record = proposed_record;\n                stopped_record.stopped_at = record.stopped_at.clone();\n                self.cleanup_worktree(&stopped_record)?;","sourceCodeStart":765,"sourceCodeEnd":801,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/lane/src/runtime.rs#L765-L801","documentation":"When the tmux runtime actually spawns the session, it runs the prepared `tmux new-session ...` command and checks the exit status; a nonzero status means tmux refused to create the session, so `start` fails. The spawn runs under a rollback guard that stops a half-created session, so this error surfaces only when tmux itself rejected the new-session invocation.","triggerScenarios":"Calling `start` (non-dry-run) where the `tmux new-session` invocation exits nonzero — invalid tmux flags, an unresolvable socket path, session name conflicts, a command that tmux's parser rejects, or the tmux server failing to start on the pinned socket.","commonSituations":"Stale or unwritable socket path in the tmux_socket pin; a session with the same name already existing on that socket; tmux flag incompatibilities with an older/newer tmux version; a shell command string with quoting issues that tmux misparses.","solutions":["Re-run the exact `tmux -S <socket> new-session ...` command by hand to see tmux's stderr.","Check whether a session with the same name already exists on the socket (`tmux -S <socket> has-session -t <name>`) and stop/rename it.","Verify the pinned socket directory exists and is writable by the runtime user.","Simplify the command/flags until tmux accepts them, then re-add pieces to isolate the offending flag or quoting."],"exampleFix":"// before (duplicate session name)\ntmux -S /tmp/lane.sock new-session -d -s lane-42 'bash'\n# duplicate session: lane-42\n\n// after: use a unique session name or kill the old one\ntmux -S /tmp/lane.sock kill-session -t lane-42 && tmux -S /tmp/lane.sock new-session -d -s lane-42 'bash'","handlingStrategy":"try-catch","validationCode":"// pre-check: socket dir writable and session name free\nassert_socket_dir_writable(socket)?;\nif tmux_session_state(socket, session)? == TmuxSessionState::Present {\n    return Err(format!(\"session {session} already exists on {socket}\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use unique session names per lane.","Verify tmux version compatibility for the flags you pass.","Quote command strings defensively when building tmux arguments."],"tags":["tmux","process","spawn"],"backgroundTag":"command-execution-failed","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}