nikivdev/code · error

Version not provided. Pass --version or set release.versioni

Error message

Version not provided. Pass --version or set release.versioning.

What it means

resolve_registry_version determines which version to publish. If no --version was given and config release.versioning is not set to a recognized calver variant ("calver"/"calendar"/"date"), it has no way to compute a version and bails with this message.

Source

Thrown at src/registry.rs:380

fn resolve_registry_version(
    cfg: &Config,
    version: Option<String>,
    registry_url: &str,
    package: &str,
) -> Result<String> {
    if let Some(version) = version {
        return Ok(version);
    }
    let versioning = cfg
        .release
        .as_ref()
        .and_then(|release| release.versioning.as_deref());
    match versioning {
        Some("calver") | Some("calendar") | Some("date") => {
            Ok(calver_version(cfg, registry_url, package))
        }
        _ => bail!("Version not provided. Pass --version or set release.versioning."),
    }
}

fn calver_version(cfg: &Config, registry_url: &str, package: &str) -> String {
    let now = Local::now();
    let mut base = format!("{}.{}.{}", now.year(), now.month(), now.day());
    let suffix = cfg
        .release
        .as_ref()
        .and_then(|release| release.calver_suffix.clone())
        .or_else(|| env::var("FLOW_CALVER_SUFFIX").ok());
    if let Some(suffix) = suffix {
        let trimmed = suffix.trim();
        if !trimmed.is_empty() {
            base = format!("{}-{}", base, trimmed);
        }
        return base;
    }

View on GitHub (pinned to a747e741ae)

Solutions

  1. Pass an explicit version: `mytool publish --version 1.2.3`.
  2. Set `release.versioning = "calver"` (or "calendar"/"date") in your config so publish derives a date-based version.
  3. Fix typos in release.versioning so it matches one of the supported values.

Example fix

// before (config.toml)
[release]
# versioning missing

// after (config.toml)
[release]
versioning = "calver"
Defensive patterns

Strategy: validation

Validate before calling

// Before publish: ensure a version is derivable
let has_version = opts.version.is_some();
let versioning = cfg.release.as_ref().and_then(|r| r.versioning.as_deref());
if !has_version && !matches!(versioning, Some("calver") | Some("calendar") | Some("date")) {
    return Err("pass --version or set release.versioning = \"calver\" in config".into());
}

Try / catch

match publish(opts.clone()) {
    Err(e) if e.to_string().contains("Version not provided") => {
        eprintln!("Supplying default version; better: fix config");
        publish(PublishOpts { version: Some("0.1.0".into()), ..opts })
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling publish without --version while config's release.versioning is absent, null, or set to an unrecognized string (the match falls to the `_` arm).

Common situations: New project where release.versioning was never configured; typo in the versioning value (e.g. "semver" when only calver modes are supported here); CI pipeline omitting the --version flag after a config change.

Understand the failure class

Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/9cbad07d382a9a14. Report an issue: GitHub.