gitbutlerapp/gitbutler · error

Too many arguments. Usage: but-installer [version|nightly]…

Error message

Too many arguments. Usage: but-installer [version|nightly] or GITBUTLER_VERSION=<version> but-installer

What it means

InstallerConfig::new enforces at most one positional argument: it collects env::args() and bails if more than two entries (program + one version) are present. The installer takes no options/flags, so any extra arguments (including unknown flags) produce this usage error.

Solutions

  1. Invoke with at most one argument: `but-installer 0.14.2` or `but-installer nightly`.
  2. Remove unknown flags — the installer supports no options; use env vars (GITBUTLER_VERSION) instead of flags.
  3. Quote shell variables and avoid unquoted globs: `but-installer "$VERSION"`.
  4. Set the channel via GITBUTLER_VERSION rather than a second positional argument.

Example fix

// before
but-installer 0.14.2 nightly
// after
but-installer nightly   # or: GITBUTLER_VERSION=0.14.2 but-installer
Defensive patterns

Strategy: validation

Validate before calling

const ARGS: usize = std::env::args().count();
assert!(ARGS <= 2, "but-installer takes at most one version argument");

Try / catch

match InstallerConfig::new() {
    Err(e) if e.to_string().contains("Too many arguments") => {
        eprintln!("{e}");
        std::process::exit(2);
    }
    Err(e) => return Err(e),
    Ok(cfg) => run(cfg),
}

Prevention

When it happens

Trigger: Running `but-installer 0.14.2 nightly`, `but-installer --verbose 0.14.2`, or passing extra shell-expanded tokens (unquoted globs matching multiple files).

Common situations: Users stacking flags from habit; scripts passing both a version and a channel; glob expansion in the working directory adding extra arguments (e.g. `but-installer *`).

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


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

Appendix: source

Thrown at crates/but-installer/src/config.rs:131

            }
        }
    }
}

/// Configuration for the installer
pub struct InstallerConfig {
    pub version_request: VersionRequest,
    pub home_dir: PathBuf,
    pub platform: String,
}

impl InstallerConfig {
    /// Create a new installer config, reading version from command-line arguments or environment
    pub fn new() -> Result<Self> {
        // Validate argument count - only 0 or 1 positional arguments allowed
        let args: Vec<String> = env::args().collect();
        if args.len() > 2 {
            bail!(
                "Too many arguments. Usage: but-installer [version|nightly] or GITBUTLER_VERSION=<version> but-installer"
            );
        }

        // Get version from CLI argument (takes precedence) or GITBUTLER_VERSION env var
        let version_string = args
            .get(1)
            .cloned()
            .or_else(|| env::var("GITBUTLER_VERSION").ok());

        let version_request = VersionRequest::from_string(version_string)?;
        Self::new_with_version(version_request)
    }

    /// Create a new installer config with an explicit version request
    pub(crate) fn new_with_version(version_request: VersionRequest) -> Result<Self> {
        let home_dir =
            dirs::home_dir().ok_or_else(|| anyhow!("Failed to determine home directory"))?;

View on GitHub (pinned to 58e5313667)