{"record":{"id":"daa9dc6bd5d1f8df","repo":"gitbutlerapp/gitbutler","slug":"too-many-arguments-usage-but-installer-version","errorCode":null,"errorMessage":"Too many arguments. Usage: but-installer [version|nightly] or GITBUTLER_VERSION=<version> but-installer","messagePattern":"Too many arguments\\. Usage: but-installer \\[version\\|nightly\\] or GITBUTLER_VERSION=<version> but-installer","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-installer/src/config.rs","lineNumber":131,"sourceCode":"            }\n        }\n    }\n}\n\n/// Configuration for the installer\npub struct InstallerConfig {\n    pub version_request: VersionRequest,\n    pub home_dir: PathBuf,\n    pub platform: String,\n}\n\nimpl InstallerConfig {\n    /// Create a new installer config, reading version from command-line arguments or environment\n    pub fn new() -> Result<Self> {\n        // Validate argument count - only 0 or 1 positional arguments allowed\n        let args: Vec<String> = env::args().collect();\n        if args.len() > 2 {\n            bail!(\n                \"Too many arguments. Usage: but-installer [version|nightly] or GITBUTLER_VERSION=<version> but-installer\"\n            );\n        }\n\n        // Get version from CLI argument (takes precedence) or GITBUTLER_VERSION env var\n        let version_string = args\n            .get(1)\n            .cloned()\n            .or_else(|| env::var(\"GITBUTLER_VERSION\").ok());\n\n        let version_request = VersionRequest::from_string(version_string)?;\n        Self::new_with_version(version_request)\n    }\n\n    /// Create a new installer config with an explicit version request\n    pub(crate) fn new_with_version(version_request: VersionRequest) -> Result<Self> {\n        let home_dir =\n            dirs::home_dir().ok_or_else(|| anyhow!(\"Failed to determine home directory\"))?;","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-installer/src/config.rs#L113-L149","documentation":"but-installer's InstallerConfig::new() (crates/but-installer/src/config.rs:127-134) accepts at most one positional argument: a semver version or the literal 'nightly'. It bails as soon as env::args() yields more than two entries (argv[0] plus one positional), because there is no way to decide which extra argument is the intended version. Flags like --help or -v are rejected here too, before VersionRequest::from_string() ever sees them.","triggerScenarios":"Invoking the installer binary produced by this crate with two or more positional arguments: 'but-installer 0.18.7 nightly', 'but-installer --version 1.2.3', or any wrapper script that forwards \"$@\" or appends flags to the installer process before calling run_installation().","commonSituations":"Users assuming the installer takes flags (--help/--version); curl|sh wrapper scripts forwarding extra shell arguments; CI jobs appending parameters to the install command line.","solutions":["Pass at most one positional argument: a version like 0.18.7 or the literal nightly","Set the version via environment instead: GITBUTLER_VERSION=<version> but-installer","If embedding the library, call run_installation_with_version(VersionRequest::Specific(...), interactive) so argv is never parsed","Filter flags and extra arguments out in wrapper scripts before invoking but-installer"],"exampleFix":"# before\nbut-installer 0.18.7 nightly\n# after\nGITBUTLER_VERSION=0.18.7 but-installer","handlingStrategy":"validation","validationCode":"// Guard argv before calling run_installation(), which parses process args\nlet args: Vec<String> = std::env::args().collect();\nif args.len() > 2 {\n    eprintln!(\"Usage: {} [version|nightly] or GITBUTLER_VERSION=<version>\", args[0]);\n    std::process::exit(2);\n}\nbut_installer::run_installation()?;","typeGuard":null,"tryCatchPattern":"if let Err(e) = but_installer::run_installation() {\n    if e.to_string().contains(\"Too many arguments\") {\n        eprintln!(\"Usage: but-installer [version|nightly] or GITBUTLER_VERSION=<version> but-installer\");\n        std::process::exit(2);\n    }\n    return Err(e);\n}","preventionTips":["Forward at most one positional argument (version or 'nightly') to but-installer","Use the GITBUTLER_VERSION env var when driving the installer from scripts","Embed run_installation_with_version() instead of run_installation() to bypass argv parsing entirely"],"tags":["rust","cli","arguments","argv","installer","but-installer"],"backgroundTag":"invalid-command-line-arguments","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}