{"record":{"id":"529bd92712ac2f89","repo":"gitbutlerapp/gitbutler","slug":"invalid-version-version-usage-but-installer","errorCode":null,"errorMessage":"Invalid version: {version}. Usage: but-installer [version|nightly]","messagePattern":"Invalid version: (.+?)\\. Usage: but-installer \\[version\\|nightly\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-installer/src/config.rs","lineNumber":52,"sourceCode":"    /// Create a new Version from a string, validating the format.\n    ///\n    /// # Errors\n    /// Returns an error if the version string is invalid.\n    pub fn new(version: String) -> Result<Self> {\n        Self::validate(&version)?;\n        Ok(Version(version))\n    }\n\n    /// Validate a version string format\n    fn validate(version: &str) -> Result<()> {\n        // Reject empty strings\n        if version.is_empty() {\n            bail!(\"Invalid version: empty string. Usage: but-installer [version|nightly]\");\n        }\n\n        // Reject if it looks like a flag\n        if version.starts_with('-') {\n            bail!(\"Invalid version: {version}. Usage: but-installer [version|nightly]\");\n        }\n\n        // Only allow semver-compatible characters\n        if !version\n            .chars()\n            .all(|c| c.is_alphanumeric() || c == '.' || c == '-' || c == '+')\n        {\n            bail!(\n                \"Invalid version format: {version}. Version must contain only alphanumeric characters, dots, hyphens, and plus signs.\"\n            );\n        }\n\n        // Must contain at least one alphanumeric character\n        if !version.chars().any(|c| c.is_alphanumeric()) {\n            bail!(\n                \"Invalid version format: {version}. Version must contain at least one alphanumeric character.\"\n            );\n        }","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-installer/src/config.rs#L34-L70","documentation":"validate rejects version strings that start with '-' (or the empty string earlier) because they would be mistaken for a command-line flag rather than a version. The raised message echoes the offending version plus the usage line.","triggerScenarios":"Invoking `but-installer --help` expecting flag handling, `but-installer -v`, or passing any value beginning with a dash (e.g. from a misparsed script variable like `VERSION=\"-rc.1\"`).","commonSituations":"Users assuming the installer takes standard CLI flags; scripts that prepend a dash to pre-release suffixes; copy-pasting `--version` from other tools' docs.","solutions":["Pass the bare version without a leading dash: `but-installer 0.14.2`.","Use `nightly` for the nightly channel instead of flag-like specifiers.","Pre-release identifiers must not carry a leading dash: use `0.14.2-rc1`, not `-rc1`.","In scripts, strip leading dashes from variables before invoking the installer."],"exampleFix":"// before\nbut-installer --0.14.2\n// after\nbut-installer 0.14.2","handlingStrategy":"validation","validationCode":"if let Some(v) = version_arg {\n    assert!(!v.starts_with('-'), \"pass the version without a leading dash: but-installer {v}\");\n}","typeGuard":null,"tryCatchPattern":"match InstallerConfig::new() {\n    Err(e) if e.to_string().contains(\"Invalid version\") => {\n        eprintln!(\"{e}\\nExpected e.g. `but-installer 0.14.2` or `but-installer nightly`\");\n        std::process::exit(2);\n    }\n    Err(e) => return Err(e),\n    Ok(cfg) => run(cfg),\n}","preventionTips":["Never prefix the version with '-'; the installer takes no flags","Attach pre-release suffixes after the semver core: 0.14.2-rc1","Strip leading dashes from version variables in wrapper scripts","Use `nightly` instead of flag-like channel specifiers"],"tags":["installer","cli","validation","version"],"backgroundTag":"invalid-cli-argument","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}