{"record":{"id":"1b2e8065e9e9c1b9","repo":"xai-org/grok-build","slug":"daemon-removeworktree-failed-e","errorCode":null,"errorMessage":"daemon RemoveWorktree failed: {e}","messagePattern":"daemon RemoveWorktree failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-fast-worktree/src/nfs/remove.rs","lineNumber":42,"sourceCode":"        if lookup_from_markers(worktree_path).is_none() {\n            bail!(\n                \"{} is a live grove mount without a backing marker; refusing rm -rf\",\n                worktree_path.display()\n            );\n        }\n    } else if dest_is_mountpoint(worktree_path) || lookup_nfs_meta(worktree_path).is_none() {\n        return Ok(None);\n    }\n    remove_nfs_worktree(worktree_path)\n}\nfn remove_nfs_worktree(worktree_path: &Path) -> Result<Option<RemoveReport>> {\n    let opts = nfs_opts_from_env_and_meta(None);\n    let client = NfsWorktreeClient::from_opts(&opts);\n    if client.ping() {\n        match client.remove_worktree(worktree_path, false) {\n            Ok(()) => return report_after_daemon_unmount(worktree_path),\n            Err(e) => {\n                bail!(\"daemon RemoveWorktree failed: {e}\");\n            }\n        }\n    }\n    if dest_is_mountpoint(worktree_path) {\n        if lookup_from_markers(worktree_path).is_none() {\n            bail!(\n                \"{} is still a mountpoint without a grove marker; refusing umount/rm\",\n                worktree_path.display()\n            );\n        }\n        plain_umount(worktree_path)?;\n    }\n    if !super::dest_is_known_unmounted(worktree_path) {\n        bail!(\n            \"unmount of {} could not be verified (still mounted or mount table \\\n             inconclusive); retaining backing and pin\",\n            worktree_path.display()\n        );","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-fast-worktree/src/nfs/remove.rs#L24-L60","documentation":"remove_nfs_worktree first asks the grove daemon to remove the worktree via client.remove_worktree. If the daemon accepts the ping but the RemoveWorktree RPC returns an error, this wraps and surfaces it as 'daemon RemoveWorktree failed', aborting the local remove path.","triggerScenarios":"Calling try_nfs_remove while the daemon is up but its remove_worktree fails: dest busy/EBUSY, backing dir missing, permission denied, worktree id lookup failed, or daemon-side unmount rejected.","commonSituations":"A process still holds files open under the mount (EBUSY); daemon lost track of the worktree after a config change; running the remove as a different user than the daemon.","solutions":["Inspect the inner error (source chain) — usually EBUSY/permission — and close processes using the mount, then retry","Check daemon logs for the RemoveWorktree failure reason","Restart the daemon to clear stale state, then retry try_nfs_remove","Fall back to the manual path: umount the dest, verify unmounted, then remove backing yourself"],"exampleFix":"// before\ntry_nfs_remove(&path)?;\n// after\nif let Err(e) = try_nfs_remove(&path) {\n    eprintln!(\"daemon remove failed: {e:#}\");\n    Command::new(\"umount\").arg(&path).status()?;\n    // verify unmounted, then remove backing dir manually\n}","handlingStrategy":"try-catch","validationCode":"// ensure no processes hold the mount before daemon removal\nlet busy = Command::new(\"fuser\").arg(\"-m\").arg(&path)\n    .stdout(Stdio::null()).status().map(|s| s.success());\nif busy == Ok(true) { eprintln!(\"mount is busy; close processes first\"); }","typeGuard":null,"tryCatchPattern":"match client.remove_worktree(worktree_path, false) {\n    Ok(()) => {}\n    Err(e) => {\n        eprintln!(\"RemoveWorktree failed: {e:#}\"); // inspect source chain for EBUSY/EACCES\n        // fall back to manual umount + verified removal\n    }\n}","preventionTips":["Close editors/shells/cd'd processes inside the worktree before removal","Run the remove as the same user as the daemon","Keep daemon logs handy and inspect the anyhow source chain"],"tags":["daemon","rpc","nfs","remove"],"backgroundTag":"rpc-operation-failed","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}