gitbutlerapp/gitbutler · error

configured storage path

Error message

configured storage path '{}' resolves to '.git' itself; choose a dedicated GitButler directory instead

What it means

When resolving a configured GitButler storage path that lives inside .git, the library validates that the path is under a dedicated subdirectory rather than at .git itself. This error fires when the configured path resolves exactly to the .git directory, which would collide with Git's own metadata.

Solutions

  1. Change the configured storage path to a dedicated subdirectory inside .git (e.g. .git/gitbutler/storage)
  2. Validate the resolved path has at least one component below .git before persisting config
  3. If the intent was a directory outside .git, configure an absolute path outside the git dir

Example fix

// before (.gitconfig)
[gitbutler]
	storagePath = .
// after
[gitbutler]
	storagePath = gitbutler/storage
Defensive patterns

Strategy: validation

Validate before calling

let rel = storage_path.strip_prefix(git_dir)?;
if rel.components().next().is_none() {
    anyhow::bail!("storage path must be a subdirectory of .git, not .git itself");
}

Type guard

fn is_dotgit_itself(p: &std::path::Path, git_dir: &std::path::Path) -> bool {
    p == git_dir
}

Try / catch

match resolve_configured_storage_path(&repo) {
    Ok(p) => p,
    Err(e) if e.to_string().contains("resolves to '.git' itself") => {
        eprintln!("fix [gitbutler] storagePath in config to a subdirectory");
        return Err(e);
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Setting the storage path configuration such that `storage_path_relative_to_git_dir` has no components (i.e. it is '.' or empty relative to the git dir) and calling `resolve_configured_storage_path`.

Common situations: A config typo where the storage dir is set to '.' or the git dir itself; automated config generation that strips the subdirectory component; migrating configs between repo layouts.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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

Appendix: source

Thrown at crates/but-project-handle/src/storage_path.rs:91

    }

    let gitdir_real = gix::path::realpath(git_dir)?;
    Ok(storage_path
        .strip_prefix(&gitdir_real)
        .ok()
        .map(Path::to_owned))
}

/// Only accept `storage_path_relative_to_git_dir` if it's a top-level `gitbutler` directory.
/// Use `storage_path` to format error messages.
fn validate_in_git_storage_path(
    storage_path_relative_to_git_dir: &Path,
    storage_path: &Path,
) -> anyhow::Result<()> {
    let Some(Component::Normal(top_level_dir)) =
        storage_path_relative_to_git_dir.components().next()
    else {
        bail!(
            "configured storage path '{}' resolves to '.git' itself; choose a dedicated GitButler directory instead",
            storage_path.display()
        );
    };

    if !top_level_dir
        .to_string_lossy()
        .get(..DEFAULT_STORAGE_DIR_NAME.len())
        .is_some_and(|name| name.eq_ignore_ascii_case(DEFAULT_STORAGE_DIR_NAME))
    {
        bail!(
            "configured storage path '{}' resolves inside '.git' but not under a top-level 'gitbutler*' directory",
            storage_path.display()
        );
    }

    Ok(())
}

View on GitHub (pinned to 58e5313667)