gitbutlerapp/gitbutler · error

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

Error message

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

What it means

`but skill install` selects the destination through either --detect (scan for existing installations) or --path (explicit directory). The pair is mutually exclusive and checked manually before any filesystem work, because supplying both makes the requested destination ambiguous.

Source

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

        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");
    }
    if ctx.is_none()
        && !global
        && let Some(custom) = custom_path.as_deref()
    {
        // Without a repository context, only absolute/tilde paths can be resolved without `--global`.
        let expanded = expand_tilde(custom).unwrap_or_else(|| PathBuf::from(custom));
        if !expanded.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 {

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Remove --detect and keep --path for an explicit destination directory
  2. Or remove --path and keep --detect to refresh an existing installation

Example fix

# before
$ but skill install --detect --path ./skills   # fails
# after
$ but skill install --path ./skills             # pick one
Defensive patterns

Strategy: validation

Validate before calling

// before spawning the CLI:
if args.detect && args.path.is_some() {
    return Err(anyhow::anyhow!("--detect and --path are mutually exclusive"));
}

Prevention

When it happens

Trigger: `but skill install --detect --path ./skills` - both flags present on the command line.

Common situations: Copy-pasted commands combining flags from different docs or tutorials, scripts accumulating flags over time, shell history editing.

Related errors


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