gitbutlerapp/gitbutler · error

Cannot use relative --path outside a git repository unless…

Error message

Cannot use relative --path outside a git repository unless --global is specified.
Use --global --path <path> for a global installation, use an absolute path, or run from within a repository for local installation.

What it means

A relative `--path` needs a base directory: either the current git repository (for a local install) or, with `--global`, the home directory. When there is no repository context (`ctx.is_none()`, e.g. run outside any git repo), `--global` was not passed, and the path is relative, install_skill cannot resolve it and bails.

Solutions

  1. Use `--global --path <path>` for a global (home-based) installation.
  2. Pass an absolute path so no base directory is needed.
  3. Run the command from inside a git repository for a local installation.

Example fix

// before (outside a repo)
but skill install --path ./skills
// error: Cannot use relative --path outside a git repository...

// after
but skill install --global --path ~/.claude/skills/gitbutler
Defensive patterns

Strategy: validation

Validate before calling

# shell: resolve to absolute path or require a repo
if [[ "$SKILL_PATH" != /* ]]; then
  git rev-parse --is-inside-work-tree >/dev/null 2>&1 || SKILL_ARGS="--global $SKILL_ARGS"
fi

Try / catch

but skill install --path "$SKILL_PATH" 2>err.log || { grep -q 'relative --path outside a git repository' err.log && but skill install --global --path "$SKILL_PATH"; }

Prevention

When it happens

Trigger: Running `but skill install --path ./skills` (relative path, no `--global`) outside of a git repository.

Common situations: Running the CLI in a non-git directory (home, /tmp) with a relative path; forgetting `--global` when intending a user-wide install.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at crates/but/src/command/skill/mod.rs:1277

    // Validate flags
    if detect && custom_path.is_some() {
        anyhow::bail!("Cannot use both --detect and --path options together");
    }
    // Only a local scope needs the repository: global installs resolve against
    // the home directory and absolute or tilde paths need no base at all.
    let custom_is_absolute = custom_path.as_deref().is_some_and(|custom| {
        expand_tilde(custom)
            .unwrap_or_else(|| PathBuf::from(custom))
            .is_absolute()
    });
    let mut ctx = if global || custom_is_absolute {
        None
    } else {
        repository_context(current_dir)?
    };
    let ctx = ctx.as_mut();
    if ctx.is_none() && !global && custom_path.is_some() && !custom_is_absolute {
        anyhow::bail!(
            "Cannot use relative --path outside a git repository unless --global is specified.\n\
             Use --global --path <path> for a global installation, use an absolute path, or run from within a repository for local installation."
        );
    }

    // Determine installation path(s). Only --detect can yield more than one, when
    // several GitButler skills share a scope; they are all refreshed together.
    let agent_default_path = if custom_path.is_none() && !detect {
        driving_agent.and_then(agent_default_install_path)
    } else {
        None
    };
    let installed_for_driving_agent = agent_default_path.is_some();
    let install_paths = if let Some(custom) = custom_path {
        vec![resolve_custom_path(&custom, ctx, global)?]
    } else if detect {
        detect_install_paths(ctx, global)?
    } else if let Some(path) = agent_default_path {

View on GitHub (pinned to 58e5313667)