gitbutlerapp/gitbutler · error
Invalid version: . Usage: but-installer [version|nightly]
Error message
Invalid version: {version}. Usage: but-installer [version|nightly] What it means
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.
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.
Example fix
// before but-installer --0.14.2 // after but-installer 0.14.2
Defensive patterns
Strategy: validation
Validate before calling
if let Some(v) = version_arg {
assert!(!v.starts_with('-'), "pass the version without a leading dash: but-installer {v}");
} Try / catch
match InstallerConfig::new() {
Err(e) if e.to_string().contains("Invalid version") => {
eprintln!("{e}\nExpected e.g. `but-installer 0.14.2` or `but-installer nightly`");
std::process::exit(2);
}
Err(e) => return Err(e),
Ok(cfg) => run(cfg),
} Prevention
- 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
When it happens
Trigger: 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"`).
Common situations: Users assuming the installer takes standard CLI flags; scripts that prepend a dash to pre-release suffixes; copy-pasting `--version` from other tools' docs.
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
- Invalid version: empty string. Usage: but-installer…
- Invalid version format
- Invalid version format
- Aborting due to empty branch name
- Aborting due to empty
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/529bd92712ac2f89.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-installer/src/config.rs:52
/// Create a new Version from a string, validating the format.
///
/// # Errors
/// Returns an error if the version string is invalid.
pub fn new(version: String) -> Result<Self> {
Self::validate(&version)?;
Ok(Version(version))
}
/// Validate a version string format
fn validate(version: &str) -> Result<()> {
// Reject empty strings
if version.is_empty() {
bail!("Invalid version: empty string. Usage: but-installer [version|nightly]");
}
// Reject if it looks like a flag
if version.starts_with('-') {
bail!("Invalid version: {version}. Usage: but-installer [version|nightly]");
}
// Only allow semver-compatible characters
if !version
.chars()
.all(|c| c.is_alphanumeric() || c == '.' || c == '-' || c == '+')
{
bail!(
"Invalid version format: {version}. Version must contain only alphanumeric characters, dots, hyphens, and plus signs."
);
}
// Must contain at least one alphanumeric character
if !version.chars().any(|c| c.is_alphanumeric()) {
bail!(
"Invalid version format: {version}. Version must contain at least one alphanumeric character."
);
}View on GitHub (pinned to 58e5313667)