Skip to content

rk riff: misleading "wt create failed: exit status 7" — worktree created but post-create init script fails, leaving an orphaned worktree and no session #258

@arnold-laishram-noon

Description

@arnold-laishram-noon

Summary

rk riff reports wt create failed: exit status 7 and aborts the whole riff, even though the git worktree was created successfully. The actual failure happened after worktree creation, in a project-level sync script (1-prerequisites.sh, which checks for a running Docker daemon). Because rk riff treats every non-zero wt create exit identically, the user is left with:

  • a misleading error — "wt create failed" when git creation actually succeeded, and
  • an orphaned worktree with no tmux window / Claude session — the riff never opens, so there's nothing to drop into and fix the prerequisite.

Repro / observed output

Running rk riff (no args) from inside a tmux session, in a project whose worktree init runs a 1-prerequisites.sh that requires Docker, with the Docker daemon not running:

➜  loom git:(main) rk riff
rk riff: wt create failed: exit status 7
── Git ─────────────────────────────────
Created worktree: misty-avocet
Path: /Users/arnoldlaishram/code/weaver/loom.worktrees/misty-avocet
Branch: misty-avocet
── Init (fab sync) ─────────────────────
Running worktree init...
Resolving kit v2.1.6 from cache...
fab/.kit-migration-version: OK (2.1.6)
Created: .claude/settings.local.json (15 permission rules)
.envrc: OK
.gitignore: OK
Claude Code: 31/31 (created 31, repaired 0, already valid 0)
Skipping OpenCode: opencode not found in PATH
Skipping Codex: codex not found in PATH
Skipping Gemini: gemini not found in PATH
Created: .claude/settings.local.json hooks (5 hook entries)
Running project-level sync scripts...
  -> 1-prerequisites.sh
fail docker-daemon
ERROR: project sync script 1-prerequisites.sh failed: exit status 1
Error: init script exited with status 1 (init output is above)
  Worktree: /Users/arnoldlaishram/code/weaver/loom.worktrees/misty-avocet  (kept — git operations succeeded)
  Retry:    cd '/Users/arnoldlaishram/code/weaver/loom.worktrees/misty-avocet' && wt init
  Remove:   wt delete 'misty-avocet'

Root cause

wt distinguishes "git creation failed" from "git creation succeeded but the init/sync step failed" — the latter is exit status 7, and wt keeps the worktree and prints wt init retry / wt delete cleanup hints (visible above).

rk riff does not make that distinction. In runWtCreate (app/backend/cmd/rk/riff.go), any non-zero exit is collapsed into one error:

out, runErr := cmd.CombinedOutput()
output := string(out)
if runErr != nil {
    return "", subprocessErr("rk riff: wt create failed: %v\n%s", runErr, output)
}

For the --count 1 path (runRiff), that error returns immediately, before spawnRiff, so no tmux window is ever opened and the created worktree is left on disk.

Expected behavior (suggestions)

rk riff could special-case wt create exit status 7 (worktree created, init failed) rather than treating it like a hard creation failure. Options:

  1. Reword the error so it doesn't claim "wt create failed" when the worktree exists — e.g. "worktree created, but wt init failed" — and surface the wt init / wt delete hints prominently.
  2. Still open the tmux window/session on exit 7 (the worktree exists), so the user can fix the prerequisite (start Docker, rerun wt init) inside the worktree instead of having to cd there manually. The worktree being "kept" by wt strongly implies it's meant to be recoverable.

At minimum, the exit-7 case should be distinguishable from a real wt create failure.

Environment

  • rk version: v2.2.13
  • wt version: v0.0.16
  • kit version: v2.1.6
  • OS: macOS (Darwin 25.5.0)
  • Project: loom (worktree init invokes a project-level 1-prerequisites.sh Docker check)

Note on the trigger

The underlying trigger in this run was simply that the Docker daemon wasn't running, so the project's 1-prerequisites.sh prerequisite check failed. Starting Docker and re-running (or cd-ing into the kept worktree and running wt init) resolves the immediate failure — but the rk riff error message and the abandoned-session behavior are what this issue is about.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions