{"record":{"id":"527235e9a5c060e2","repo":"zed-industries/zed","slug":"cannot-re-verify-approved-sandbox-write-grant","errorCode":null,"errorMessage":"cannot re-verify approved sandbox write grant `{}` (if the directory was removed, remove the grant or recreate the directory)","messagePattern":"cannot re-verify approved sandbox write grant `(.+?)` \\(if the directory was removed, remove the grant or recreate the directory\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/acp_thread/src/terminal.rs","lineNumber":288,"sourceCode":"            sandbox::SandboxFsPolicy::Unrestricted { protected_paths }\n        } else {\n            // Project worktree paths are captured fresh; user-approved grants are\n            // rebuilt via the verifying reopen (or captured when legacy bare\n            // strings) through `granted_write_path_to_location`. A path that\n            // can't be captured fails the whole construction (never created).\n            let mut locations = Vec::new();\n            for path in &self.writable_paths {\n                let location = sandbox::HostFilesystemLocation::capture(path).map_err(|error| {\n                    anyhow::anyhow!(error).context(format!(\n                        \"cannot capture writable sandbox path `{}`\",\n                        path.display()\n                    ))\n                })?;\n                locations.push(location);\n            }\n            for granted in &self.extra_write_paths {\n                let location = granted_write_path_to_location(granted).map_err(|error| {\n                    anyhow::anyhow!(error).context(format!(\n                        \"cannot re-verify approved sandbox write grant `{}` (if the \\\n                         directory was removed, remove the grant or recreate the \\\n                         directory)\",\n                        granted.requested.display()\n                    ))\n                })?;\n                locations.push(location);\n            }\n            // Dedupe to a minimal cover on the captured canonical paths, so a\n            // grant nested under a worktree root (or another grant) is dropped\n            // rather than bound redundantly.\n            let writable_paths =\n                sandbox::normalize_host_filesystem_locations(locations.into_iter());\n            sandbox::SandboxFsPolicy::Restricted {\n                writable_paths,\n                protected_paths,\n            }\n        };","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/acp_thread/src/terminal.rs#L270-L306","documentation":"User-approved extra write grants (extra_write_paths) are re-verified on every sandbox construction via granted_write_path_to_location; if the approved directory cannot be re-verified (typically removed or moved since approval), construction fails with this message, which also tells the user the two ways out: remove the grant or recreate the directory. Like writable_paths, this is deliberately fail-closed — a grant that cannot be verified is never silently downgraded.","triggerScenarios":"The user approved a writable directory for the agent, that directory was later deleted/moved (clean task removed a build dir, worktree pruned), and the next agent terminal spawn re-verifies the grant and fails.","commonSituations":"Approved a temp/build output directory that a clean script removes; approved a path inside a worktree that got deleted; state persisted across sessions while the filesystem changed underneath.","solutions":["Recreate the directory named in the error (mkdir -p the printed path)","Or remove the stale grant via the agent's permissions UI/settings, exactly as the message instructs"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before terminal spawn, verify approved grants still point at real dirs\nlet stale: Vec<_> = extra_write_paths.iter()\n    .filter(|g| !g.requested.exists())\n    .cloned()\n    .collect();\nfor grant in stale {\n    prompt_user(format!(\n        \"approved write grant {} no longer exists; remove it?\",\n        grant.requested.display()\n    ));\n}","typeGuard":"fn grant_targets_exist(grants: &[WriteGrant]) -> bool {\n    grants.iter().all(|g| g.requested.is_dir())\n}","tryCatchPattern":null,"preventionTips":["Recreate directories named in the error (mkdir -p) before respawning the agent terminal","Prune approved grants for directories that a clean step routinely deletes","Prefer approving stable directories over ephemeral build output paths"],"tags":["rust","zed","sandbox","permissions","filesystem"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}