{"record":{"id":"637a53ec82434892","repo":"gitbutlerapp/gitbutler","slug":"path-is-not-a-directory-path","errorCode":null,"errorMessage":"Path is not a directory: {path}","messagePattern":"Path is not a directory: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/open/mod.rs","lineNumber":539,"sourceCode":"        fn create_new_console(cmd: &mut Command) -> &mut Command {\n            use std::os::windows::process::CommandExt;\n            // CREATE_NEW_CONSOLE: Creates a new console for the process (0x00000010)\n            // This allows the terminal to run independently without blocking our thread\n            const CREATE_NEW_CONSOLE: u32 = 0x00000010;\n            cmd.creation_flags(CREATE_NEW_CONSOLE)\n        }\n        #[cfg(not(windows))]\n        fn create_new_console(cmd: &mut Command) -> &mut Command {\n            cmd\n        }\n\n        // Validate path exists and canonicalize it to proper Windows format\n        let path_buf = Path::new(&path);\n        if !path_buf.exists() {\n            bail!(\"Path does not exist: {path}\");\n        }\n        if !path_buf.is_dir() {\n            bail!(\"Path is not a directory: {path}\");\n        }\n\n        // Canonicalize to get the absolute, properly formatted Windows path\n        // This converts forward slashes to backslashes and resolves . and ..\n        let canonical_path = gix::path::realpath(path_buf)\n            .with_context(|| format!(\"Failed to canonicalize path: {path}\"))?\n            .to_str()\n            .context(\"BUG: input path is String, should be able to convert back to it\")?\n            .to_owned();\n        let canonical_path = &canonical_path;\n\n        // Check if the terminal binary exists in PATH before attempting to launch.\n        let binary_found = which::which(&terminal_id).is_ok();\n        if !binary_found {\n            return Err(anyhow::anyhow!(\"'{terminal_id}' was not found.\")\n                .context(but_error::Code::DefaultTerminalNotFound));\n        }\n","sourceCodeStart":521,"sourceCodeEnd":557,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/open/mod.rs#L521-L557","documentation":"Immediately after the existence check, the Windows branch requires the path to be a directory; if it exists but is a file, open_in_terminal() bails with this error. Terminals are launched with a working directory, so a file path is not a valid target.","triggerScenarios":"Calling open_in_terminal on Windows with a path to a regular file instead of a directory (e.g. a file selected instead of the project folder).","commonSituations":"UI passes the currently-open file instead of the project root, or a path stored from a file-picker that pointed at a file.","solutions":["Pass the project/repository root directory, not a file","Derive the directory from the file path (e.g. path.parent()) before calling","Check the caller that supplies the path to ensure it resolves to a directory"],"exampleFix":"// before\nopen_in_terminal(\"powershell\", \"C:\\\\repos\\\\proj\\\\README.md\")\n// after\nopen_in_terminal(\"powershell\", \"C:\\\\repos\\\\proj\")","handlingStrategy":"validation","validationCode":"import { existsSync, statSync } from 'fs';\nfunction isDirectory(p: string): boolean { return existsSync(p) && statSync(p).isDirectory(); }","typeGuard":"fn is_dir(p: &str) -> bool { Path::new(p).is_dir() }","tryCatchPattern":null,"preventionTips":["Always pass the project root, never a file path","Derive parent directories from file paths before invoking","Validate path parameters at the API boundary"],"tags":["path","windows","directory"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}