gitbutlerapp/gitbutler · warning

Cannot attempt to open non-existing directory: '{}'

Error message

Cannot attempt to open non-existing directory: '{}'

What it means

open_existing (crates/gitbutler-tauri/src/debug.rs) powers debug commands like open_cache_folder: it opens a directory with the OS file manager but refuses when dir.exists() is false, erroring with the path included. A sibling check rejects paths that exist but are not directories. It exists so debug helpers fail loudly instead of the OS open failing silently.

Source

Thrown at crates/gitbutler-tauri/src/debug.rs:33

#[instrument(err(Debug))]
pub fn open_config_folder() -> Result<(), Error> {
    open_existing(but_path::app_config_dir()?)
}

/// Opens the cache folder in the system file manager
#[instrument(err(Debug))]
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.

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Trigger normal app usage once so startup code creates the cache directory, then retry
  2. Verify the resolved path: on Linux check $XDG_CACHE_HOME/… overrides, on macOS ~/Library/Caches/…, on Windows the LocalAppData cache dir
  3. Create the directory yourself if the app should be robust here: std::fs::create_dir_all before open_existing
  4. If the path exists but still errors, you are hitting the is_dir branch — make sure it is a directory

Example fix

// before
fn open_cache_folder() -> Result<(), Error> {
    open_existing(but_path::app_cache_dir()?)
}

// after: ensure the directory exists before opening it
fn open_cache_folder() -> Result<(), Error> {
    let dir = but_path::app_cache_dir()?;
    std::fs::create_dir_all(&dir).ok(); // first run: cache dir may not exist yet
    open_existing(dir)
}
Defensive patterns

Strategy: validation

Validate before calling

let dir = but_path::app_cache_dir()?;
if !dir.exists() {
    std::fs::create_dir_all(&dir)?; // first run: create before opening
}
open_existing(dir)?;

Type guard

fn existing_directory(p: &Path) -> Option<&Path> {
    p.exists().then_some(p).filter(|p| p.is_dir())
}

Try / catch

match open_existing(but_path::app_cache_dir()?) {
    Ok(()) => Ok(()),
    Err(err) if err.to_string().contains("non-existing directory") => {
        // create and retry once — cache dirs may simply not exist yet on first run
        let dir = but_path::app_cache_dir()?;
        std::fs::create_dir_all(&dir)?;
        open_existing(dir)
    }
    Err(err) => Err(err),
}

Prevention

When it happens

Trigger: Invoking the open-cache-folder debug command before the app ever created its cache directory; but_path::app_cache_dir() resolving to a custom/missing location (XDG_CACHE_HOME override on Linux, portable/shifted app data on Windows/macOS); the cache dir having been deleted while the app runs.

Common situations: Debug menu used right after a fresh install before first-run dir creation; users with redirected/overridden cache paths; cache cleaned by disk-cleanup tools mid-session; misbuilt portable installs where the cache path lands somewhere read-only or absent.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20). Data as JSON: /api/errors/4b08c5236834b427. Report an issue: GitHub.