{"record":{"id":"39d03d7db4214e29","repo":"gitbutlerapp/gitbutler","slug":"cannot-attempt-to-open-anything-but-a-directory","errorCode":null,"errorMessage":"Cannot attempt to open anything but a directory: '{}'","messagePattern":"Cannot attempt to open anything but a directory: '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/gitbutler-tauri/src/debug.rs","lineNumber":40,"sourceCode":"pub fn open_cache_folder() -> Result<(), Error> {\n    open_existing(but_path::app_cache_dir()?)\n}\n\n/// Open `dir` but refuse to do so if that would definitely fail as it's not a directory,\n/// or it doesn't exist.\n///\n/// We can assume the directories exist.\nfn open_existing(dir: impl AsRef<Path>) -> Result<(), Error> {\n    let dir = dir.as_ref();\n    if !dir.exists() {\n        return Err(anyhow!(\n            \"Cannot attempt to open non-existing directory: '{}'\",\n            dir.display()\n        )\n        .into());\n    }\n    if !dir.is_dir() {\n        return Err(anyhow!(\n            \"Cannot attempt to open anything but a directory: '{}'\",\n            dir.display()\n        )\n        .into());\n    }\n\n    let is_macos_stable_build =\n        cfg!(target_os = \"macos\") && matches!(AppChannel::new(), AppChannel::Release);\n    // On macOS stable builds, it would try to open `com.gitbutler.app` and treat it as application,\n    // which would fail. Instead, we reveal, which selects the directory in the finder and users\n    // can right-click it to see the package contents. Better than nothing.\n    // Maybe we can rename the application ID at some point.\n    if is_macos_stable_build {\n        reveal_directory(dir)\n    } else {\n        open::that(dir).map_err(anyhow::Error::from)\n    }\n    .with_context(|| format!(\"Failed to open directory at '{dir}'\", dir = dir.display()))","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/gitbutler-tauri/src/debug.rs#L22-L58","documentation":"open_existing() verifies the path is actually a directory after checking existence; if it's a file or symlink to a file, it returns this error. It protects the OS 'open folder in file manager' call from receiving a non-directory path.","triggerScenarios":"Passing a path that exists but is a regular file (or other non-dir) to open_existing via open_logs_folder/open_config_folder/open_cache_folder — e.g. the configured 'logs dir' points at a file.","commonSituations":"Custom config overriding a folder setting with a file path; a file accidentally created where the folder should be (same name); misconfigured cache dir in portable mode.","solutions":["Check the path with `ls -la` and remove/rename the offending file so a directory can exist there.","Fix the app setting that points logs/config/cache at a file path.","Delete the stale file and restart the app so the directory is recreated."],"exampleFix":"// before\n$ mv ~/Library/Logs/gitbutler ~/logs-backup   # logs path is a file\n// after\n$ rm ~/Library/Logs/gitbutler                 # remove file blocking the dir\n$ mkdir ~/Library/Logs/gitbutler","handlingStrategy":"validation","validationCode":"const st = fs.statSync(dirPath);   // throws if missing\nif (!st.isDirectory()) throw new Error(`${dirPath} is not a directory`);","typeGuard":"const isDirectory = (p) => { try { return fs.statSync(p).isDirectory(); } catch { return false; } };","tryCatchPattern":"try { open_config_folder(); } catch (e) { if (String(e).includes('anything but a directory')) { repairConfigDirPath(); } else { throw e; } }","preventionTips":["Never configure folder settings to point at files.","Use stat().isDirectory() checks before opening paths in a file manager.","Recreate folders if a same-named file blocks the path."],"tags":["filesystem","tauri","path"],"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"}