gitbutlerapp/gitbutler · error
Invalid version: empty string. Usage: but-installer…
Error message
Invalid version: empty string. Usage: but-installer [version|nightly]
What it means
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`.
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.
Example fix
// before GITBUTLER_VERSION= but-installer // after GITBUTLER_VERSION=0.14.2 but-installer # or: but-installer nightly
Defensive patterns
Strategy: validation
Validate before calling
const VERSION: Option<&str> = option_env!("GITBUTLER_VERSION");
assert!(VERSION.map_or(false, |v| !v.trim().is_empty()), "set a version argument or GITBUTLER_VERSION"); Try / catch
match InstallerConfig::new() {
Err(e) if e.to_string().contains("empty string") => {
eprintln!("No version given; defaulting to nightly");
// rerun with explicit version or fall back to nightly
}
Err(e) => return Err(e),
Ok(cfg) => run(cfg),
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
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 format
- Invalid version format
- Invalid version: . Usage: but-installer [version|nightly]
- 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/cde711322ebc6d8d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-installer/src/config.rs:47
/// - Contains at least one alphanumeric character
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Version(String);
impl Version {
/// 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 characterView on GitHub (pinned to 58e5313667)