{"record":{"id":"cde711322ebc6d8d","repo":"gitbutlerapp/gitbutler","slug":"invalid-version-empty-string-usage-but-installe","errorCode":null,"errorMessage":"Invalid version: empty string. Usage: but-installer [version|nightly]","messagePattern":"Invalid version: empty string\\. Usage: but-installer \\[version\\|nightly\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-installer/src/config.rs","lineNumber":47,"sourceCode":"/// - Contains at least one alphanumeric character\n#[derive(Debug, Clone, PartialEq, Eq)]\npub struct Version(String);\n\nimpl Version {\n    /// 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","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-installer/src/config.rs#L29-L65","documentation":"InstallerConfig::validate rejects an empty version string before any download is attempted. The installer derives the target version from argv or GITBUTLER_VERSION; if it ends up empty (no argument given and the env var unset/blank), this usage error is raised telling the caller to pass a version or `nightly`.","triggerScenarios":"Running `but-installer` with no positional argument while GITBUTLER_VERSION is unset or set to empty string (`GITBUTLER_VERSION= but-installer`), so version_string resolves to \"\" and reaches validate.","commonSituations":"CI script interpolating a variable that is empty at that stage; user forgot the argument; wrapper script exporting GITBUTLER_VERSION=\"\" ; shell expanding to empty under `set -u` avoidance hacks.","solutions":["Pass a version explicitly: `but-installer 0.14.2` or `but-installer nightly`.","Export GITBUTLER_VERSION with a non-empty value before invoking the installer.","In scripts, guard with `[ -n \"$GITBUTLER_VERSION\" ] || { echo 'version required'; exit 1; }` before calling.","Default to `nightly` when neither argument nor env var is present if a pinned version is not required."],"exampleFix":"// before\nGITBUTLER_VERSION= but-installer\n// after\nGITBUTLER_VERSION=0.14.2 but-installer   # or: but-installer nightly","handlingStrategy":"validation","validationCode":"const VERSION: Option<&str> = option_env!(\"GITBUTLER_VERSION\");\nassert!(VERSION.map_or(false, |v| !v.trim().is_empty()), \"set a version argument or GITBUTLER_VERSION\");","typeGuard":null,"tryCatchPattern":"match InstallerConfig::new() {\n    Err(e) if e.to_string().contains(\"empty string\") => {\n        eprintln!(\"No version given; defaulting to nightly\");\n        // rerun with explicit version or fall back to nightly\n    }\n    Err(e) => return Err(e),\n    Ok(cfg) => run(cfg),\n}","preventionTips":["Always pass an explicit version or `nightly` as the single positional argument","In CI, assert the version variable is non-empty before invoking the installer","Avoid `VAR= cmd` patterns that set the env var to empty","Default to `nightly` in wrapper scripts when no version is supplied"],"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"}