{"record":{"id":"c6e61576aca900a2","repo":"Hmbown/CodeWhale","slug":"source-is-not-a-directory-resume-fork-from","errorCode":null,"errorMessage":"{source} is not a directory: {}. Resume/fork from an existing workspace or pass an explicit `working_dir`/`cwd`","messagePattern":"(.+?) is not a directory: (.+?)\\. Resume/fork from an existing workspace or pass an explicit `working_dir`/`cwd`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/shell.rs","lineNumber":143,"sourceCode":"fn validate_shell_working_dir(path: &Path, inherited_session_workspace: bool) -> Result<()> {\n    let metadata = std::fs::metadata(path).with_context(|| {\n        let source = if inherited_session_workspace {\n            \"saved session workspace\"\n        } else {\n            \"requested working directory\"\n        };\n        format!(\n            \"{source} is unavailable: {}. Restore or remap that directory, resume/fork the session from an existing workspace, or pass an explicit `working_dir`/`cwd` to exec_shell\",\n            path.display()\n        )\n    })?;\n    if !metadata.is_dir() {\n        let source = if inherited_session_workspace {\n            \"saved session workspace\"\n        } else {\n            \"requested working directory\"\n        };\n        return Err(anyhow!(\n            \"{source} is not a directory: {}. Resume/fork from an existing workspace or pass an explicit `working_dir`/`cwd`\",\n            path.display()\n        ));\n    }\n    Ok(())\n}\n\n/// Status of a shell process.\n#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]\npub enum ShellStatus {\n    Running,\n    Completed,\n    Failed,\n    Killed,\n    TimedOut,\n}\n\n/// Result from a shell command execution.","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/shell.rs#L125-L161","documentation":"`validate_shell_working_dir` checks that the workspace the shell tool will run in exists and is a directory. When a saved session workspace or an explicitly requested `working_dir`/`cwd` resolves to something missing or non-directory (file, symlink to nothing, deleted path), execution is refused with guidance to resume/fork from a valid workspace or pass an explicit directory.","triggerScenarios":"Executing the shell tool after resuming/forking a session whose saved workspace path no longer exists or now points to a file; passing an explicit `working_dir`/`cwd` that is not a directory.","commonSituations":"Resuming a session from a machine/container where /tmp was cleaned or the project moved; a workspace directory deleted while the session was open; typos or relative paths in `working_dir`; a path that was a directory replaced by a file.","solutions":["Pass an explicit `working_dir`/`cwd` pointing to an existing directory","Resume/fork from a workspace that still exists on disk (recreate the path if it was deleted)","Check the saved session workspace path exists (`ls <path>`) before resuming","Fix typos or convert relative paths to absolute existing directories"],"exampleFix":"// before\nshell({\"command\": \"cargo test\"})  // saved workspace was deleted\n// after\nshell({\"command\": \"cargo test\", \"working_dir\": \"/home/me/project\"})","handlingStrategy":"validation","validationCode":"let wd = opts.working_dir.as_ref().or(saved_workspace.as_ref()); if let Some(p) = wd { if !p.is_dir() { return Err(anyhow!(\"working dir missing or not a directory: {}\", p.display())); } }","typeGuard":"fn is_valid_working_dir(p: &Path) -> bool { p.is_dir() }","tryCatchPattern":"match shell_execute(opts) { Err(e) if e.to_string().contains(\"is not a directory\") => { let wd = prompt_for_existing_dir(); shell_execute(opts.with_working_dir(wd)) }, Err(e) => Err(e), Ok(v) => Ok(v) }","preventionTips":["Verify the saved session workspace still exists before resuming/forking","Always pass an absolute, existing directory for working_dir/cwd","Recreate or re-point workspaces after container restarts or /tmp cleanups","Check that the path wasn't replaced by a file (e.g. by tooling) before running shell commands"],"tags":["shell","working-directory","workspace","validation"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}