xai-org/grok-build · error
worktree not found: {id_or_path}
Error message
worktree not found: {id_or_path} What it means
cmd_show resolves a worktree by id or path; if the lookup returns no record, it bails with `worktree not found: {id_or_path}`. The record may have been removed or never existed — the identifier supplied by the user matched nothing in the worktree store.
Source
Thrown at crates/codegen/xai-grok-pager/src/worktree_cmd/mod.rs:189
display::print_json(&records, &mut out)
} else {
display::print_table(&records, &mut out)
};
Ok(crate::util::ignore_broken_pipe(written)?)
}
async fn cmd_show(tx: &xai_acp_lib::AcpAgentTx, id_or_path: &str) -> Result<()> {
let rec: Option<WorktreeRecord> = ext_call(
tx,
"x.ai/git/worktree/show",
&serde_json::json!({ "idOrPath" : id_or_path }),
)
.await?;
match rec {
Some(r) => {
let written = display::print_show(&r, &mut std::io::stdout().lock());
Ok(crate::util::ignore_broken_pipe(written)?)
}
None => bail!("worktree not found: {id_or_path}"),
}
}
#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
struct RemoveResponse {
removed: bool,
#[serde(default)]
resolved_path: Option<String>,
}
async fn cmd_rm(
tx: &xai_acp_lib::AcpAgentTx,
ids: Vec<String>,
force: bool,
dry_run: bool,
) -> Result<()> {
for id_or_path in &ids {
let resp: Result<RemoveResponse> = ext_call(
tx,View on GitHub (pinned to bc7f02eddd)
Solutions
- Run `grok worktree list` to see valid ids/paths and re-run show with one of them.
- Use the exact absolute path if addressing by path.
- If it was garbage-collected, recreate the worktree instead of showing it.
Example fix
// before grok worktree show wt_abc123 # stale id // after grok worktree list grok worktree show wt_def456
Defensive patterns
Strategy: validation
Validate before calling
fn worktree_exists(id_or_path: &str) -> bool {
worktree_list()
.map(|list| {
list.iter().any(|w| {
w.id == id_or_path
|| std::path::Path::new(&w.path).canonicalize().ok()
== std::path::Path::new(id_or_path).canonicalize().ok()
})
})
.unwrap_or(false)
}
if !worktree_exists(id) { eprintln!("unknown worktree: {id}"); return; } Prevention
- Always obtain ids from `grok worktree list`, not from memory or old scripts.
- Use absolute canonical paths when addressing worktrees by path.
- Account for gc: recent garbage collection may have removed the worktree.
When it happens
Trigger: Running `grok worktree show <id_or_path>` where the id or path does not correspond to any existing worktree record in the store.
Common situations: Worktree already removed (manually or by gc); typo in the id; passing a relative path when the store keys by absolute path; stale ids cached in scripts.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- session '{name}' not found
- Session does not exist: {}
- Session does not exist
- Plugin "{name}" not found. Run `grok plugin list` to see ins
- Marketplace source "{filter}" not found.
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/a38114a1a711e8c2.
Report an issue: GitHub.