{"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/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-installer/src/config.rs#L34-L70","documentation":"Thrown by but-installer's Version::validate (crates/but-installer/src/config.rs:52) when the version argument starts with '-', i.e., it looks like a command-line flag (e.g., --help, -v) rather than a version. The validator rejects it because a leading dash would be ambiguous with flag parsing downstream; the usage hint in the message says the accepted forms are a plain version or `nightly`.","triggerScenarios":"Running `but-installer --help` or `but-installer -v` (the tool treats it as a version, not a flag); a script passing \"$@\" where the first extra token is a flag; negative-looking strings like \"-1.2.3\".","commonSituations":"Users trying to discover flags with --help; argument misordering in wrapper scripts; a version variable accidentally containing a leading dash.","solutions":["Remove the leading dash: pass `1.2.3` not `-1.2.3`","If you wanted help, run the command without arguments or consult its docs — this installer accepts only a version or `nightly`","Fix argument ordering in scripts so flags are not forwarded into the version position"],"exampleFix":"# before\nbut-installer -1.2.3   # rejected: looks like a flag\n\n# after\nbut-installer 1.2.3","handlingStrategy":"validation","validationCode":"let version = version.trim();\nif version.starts_with('-') {\n    eprintln!(\"'{version}' looks like a flag; expected a version like 1.2.3 or 'nightly'\");\n    std::process::exit(2);\n}\nlet v = Version::new(version.to_string())?;","typeGuard":"fn looks_like_flag(v: &str) -> bool { v.starts_with('-') }","tryCatchPattern":"if let Err(err) = Version::new(version) {\n    if err.to_string().contains(\"Usage: but-installer\") { eprintln!(\"pass a plain version (1.2.3) or 'nightly', not flags\"); std::process::exit(2); }\n    return Err(err);\n}","preventionTips":["Strip leading 'v'/dashes before passing tags: version=${version#v}","Do not forward unknown script flags into the version argument position"],"tags":["but-installer","version","cli","argument-parsing","rust"],"backgroundTag":"invalid-version-string","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}