gitbutlerapp/gitbutler · warning

Cannot attempt to open non-existing directory

Error message

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

What it means

open_existing() in the Tauri debug module opens a folder in the OS file manager. It first asserts the directory exists; if not, it returns this anyhow error wrapped as Error. Although callers normally pass directories that already exist, this guards against a missing logs/config/cache folder.

Solutions

  1. Trigger the action that creates the folder first (produce a log, save settings) and retry.
  2. Manually create the missing folder and retry the open.
  3. Reinstall/relaunch the app so default folders are initialized.

Example fix

// before (caller)
open_logs_folder()?;
// after
std::fs::create_dir_all(&logs_dir)?;
open_logs_folder()?;
Defensive patterns

Strategy: validation

Validate before calling

if (!fs.existsSync(logsDir)) fs.mkdirSync(logsDir, { recursive: true });
open_logs_folder();

Type guard

const dirExists = (p) => fs.existsSync(p) && fs.statSync(p).isDirectory();

Try / catch

try { open_logs_folder(); } catch (e) { if (String(e).includes('non-existing directory')) { fs.mkdirSync(logsDir, {recursive:true}); open_logs_folder(); } else { throw e; } }

Prevention

When it happens

Trigger: Calling open_logs_folder, open_config_folder, or open_cache_folder before the corresponding directory has been created (e.g. on first launch before any log/config write, or when cache was cleared externally).

Common situations: Fresh install where the user clicks 'Open logs' before anything was logged; cache directory deleted by a cleanup tool; portable/custom-dir installs where the dir was never initialized.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/4b08c5236834b427. Report an issue: GitHub.

Appendix: 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 58e5313667)