gitbutlerapp/gitbutler · error

Cannot use both --detect and --path options together

Error message

Cannot use both --detect and --path options together

What it means

`install_skill` treats `--detect` (auto-discover and update existing installations) and `--path` (explicit directory) as mutually exclusive ways to choose install locations. Passing both is ambiguous, so it bails during flag validation.

Solutions

  1. Remove `--path` if you want auto-detection of existing installations.
  2. Remove `--detect` if you want to install into the explicitly given `--path`.

Example fix

// before
but skill install --detect --path ~/.claude/skills/gitbutler
// error: Cannot use both --detect and --path options together

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

Strategy: validation

Validate before calling

# shell
if [ -n "$DETECT" ] && [ -n "$PATH_OPT" ]; then echo "choose --detect OR --path"; exit 1; fi

Try / catch

but skill install --detect 2>err.log || { grep -q 'both --detect and --path' err.log && echo 'remove one of the flags'; }

Prevention

When it happens

Trigger: Running `but skill install --detect --path <dir>` (any subcommand routed through install_skill with both flags set).

Common situations: Copy-pasting flag examples together; scripts that always append `--path` while a wrapper adds `--detect`.

Understand the failure class

Background: "mutually exclusive" flag errors: what "can't supply both nx and xx", "--raw is not compatible with -i" and "cannot be used with" mean, and how to fix them — this error's family across 29 libraries.

Related errors


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

Appendix: source

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

        SKILL_FILES.iter().all(|file| {
            !file.path_components.is_empty()
                && file
                    .path_components
                    .iter()
                    .all(|component| !component.is_empty())
                && file
                    .path_components
                    .iter()
                    .all(|component| !component.contains('/') && !component.contains('\\'))
        }),
        "SkillFile path components must be non-empty and separator-free"
    );

    let mut progress = out.progress_channel();

    // 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."

View on GitHub (pinned to 58e5313667)