gitbutlerapp/gitbutler · warning
Cannot attempt to open anything but a directory
Error message
Cannot attempt to open anything but a directory: '{}' What it means
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.
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.
Example fix
// before $ mv ~/Library/Logs/gitbutler ~/logs-backup # logs path is a file // after $ rm ~/Library/Logs/gitbutler # remove file blocking the dir $ mkdir ~/Library/Logs/gitbutler
Defensive patterns
Strategy: validation
Validate before calling
const st = fs.statSync(dirPath); // throws if missing
if (!st.isDirectory()) throw new Error(`${dirPath} is not a directory`); Type guard
const isDirectory = (p) => { try { return fs.statSync(p).isDirectory(); } catch { return false; } }; Try / catch
try { open_config_folder(); } catch (e) { if (String(e).includes('anything but a directory')) { repairConfigDirPath(); } else { throw e; } } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Cannot attempt to open non-existing directory
- failed to create app settings
- failed to create config dir
- failed to create logs dir
- project path is not a directory
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/39d03d7db4214e29.
Report an issue: GitHub.
Appendix: source
Thrown at crates/gitbutler-tauri/src/debug.rs:40
pub fn open_cache_folder() -> Result<(), Error> {
open_existing(but_path::app_cache_dir()?)
}
/// Open `dir` but refuse to do so if that would definitely fail as it's not a directory,
/// or it doesn't exist.
///
/// We can assume the directories exist.
fn open_existing(dir: impl AsRef<Path>) -> Result<(), Error> {
let dir = dir.as_ref();
if !dir.exists() {
return Err(anyhow!(
"Cannot attempt to open non-existing directory: '{}'",
dir.display()
)
.into());
}
if !dir.is_dir() {
return Err(anyhow!(
"Cannot attempt to open anything but a directory: '{}'",
dir.display()
)
.into());
}
let is_macos_stable_build =
cfg!(target_os = "macos") && matches!(AppChannel::new(), AppChannel::Release);
// On macOS stable builds, it would try to open `com.gitbutler.app` and treat it as application,
// which would fail. Instead, we reveal, which selects the directory in the finder and users
// can right-click it to see the package contents. Better than nothing.
// Maybe we can rename the application ID at some point.
if is_macos_stable_build {
reveal_directory(dir)
} else {
open::that(dir).map_err(anyhow::Error::from)
}
.with_context(|| format!("Failed to open directory at '{dir}'", dir = dir.display()))View on GitHub (pinned to 58e5313667)