Hmbown/CodeWhale · error

repo root does not exist

Error message

repo root does not exist: {}

What it means

Input validation in `provision_worktree` (crates/lane/src/worktree.rs): `spec.repo_root` does not exist on disk, checked via `Path::exists()` before creating the worktree. Git cannot add a worktree relative to a nonexistent repository root, so the library fails with the path in the message.

Solutions

  1. Pass the absolute, existing path of the git repository as `repo_root`.
  2. Clone or create the repository before provisioning the worktree.
  3. Canonicalize the configured repo root once at startup and reuse that value.

Example fix

// before
repo_root: PathBuf::from("../my-repo")
// after
let repo_root = std::fs::canonicalize("/work/my-repo")?;
WorktreeProvision { repo_root, .. }
Defensive patterns

Strategy: validation

Validate before calling

let repo_root = std::fs::canonicalize(&spec.repo_root)?; // errors early if missing
anyhow::ensure!(repo_root.join(".git").exists(), "not a repo: {}", repo_root.display());

Type guard

fn repo_ready(p: &Path) -> bool { p.exists() && p.join(".git").exists() }

Prevention

When it happens

Trigger: Calling `provision_worktree` with `repo_root` pointing to a missing directory — wrong relative path, deleted/temp repo, or a root created after provisioning was invoked.

Common situations: Running the tool from a copied/sandboxed directory where the repo root path changed; typos in a configured repo root; calling provisioning before cloning the repository; tests using a temp dir that was already cleaned up.

Related errors


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

Appendix: source

Thrown at crates/lane/src/worktree.rs:36

    /// Directory for the new worktree (created by `git worktree add`).
    pub path: PathBuf,
    /// Base ref to branch from (default `HEAD`).
    pub base_ref: Option<String>,
}

#[derive(Debug, Clone)]
pub struct ProvisionedWorktree {
    pub path: PathBuf,
    pub branch: String,
}

/// Create a git worktree + branch for a lane.
pub fn provision_worktree(spec: &WorktreeProvision) -> Result<ProvisionedWorktree> {
    if spec.branch.trim().is_empty() {
        bail!("worktree branch must not be empty");
    }
    if !spec.repo_root.exists() {
        bail!("repo root does not exist: {}", spec.repo_root.display());
    }
    if let Some(parent) = spec.path.parent() {
        fs::create_dir_all(parent)
            .with_context(|| format!("create worktree parent {}", parent.display()))?;
    }
    let base = spec.base_ref.as_deref().unwrap_or("HEAD");
    // Capture git output instead of inheriting the caller's terminal. Runtime
    // callers include the raw-mode TUI launch screen, where even one inherited
    // progress/error line corrupts the alternate-screen buffer.
    let output = Command::new("git")
        .current_dir(&spec.repo_root)
        .args([
            "worktree",
            "add",
            "-b",
            &spec.branch,
            &spec.path.to_string_lossy(),
            base,

View on GitHub (pinned to 73e0f67d83)