astrid-runtime/astrid · error

running astrid version

Error message

running astrid version {RUNNING_ASTRID_VERSION:?} is not valid semver: {e}

What it means

enforce_astrid_version parses the running CLI's own version constant (RUNNING_ASTRID_VERSION) as semver before comparing it against the manifest's astrid-version floor. Failure means the binary was built with a version string that is not valid semver — per the code comment, a build-time defect, not a problem with the distro manifest.

Solutions

  1. Rebuild/reinstall astrid from an official release so RUNNING_ASTRID_VERSION is a clean semver triple.
  2. Fix the build script that stamps the version to emit valid semver (strip 'v' prefix, convert git-describe to valid prerelease/build metadata).
  3. Check `astrid --version` output and compare against semver.org rules to see what is malformed.

Example fix

// before: build.rs
println!("cargo:rustc-env=RUNNING_ASTRID_VERSION={}", git_describe); // "0.6.0-3-gabc"
// after
let v = git_describe.trim_start_matches('v');
let v = v.replace("-g", "+g"); // "0.6.0-3+gabc" -> precompute a valid semver instead
println!("cargo:rustc-env=RUNNING_ASTRID_VERSION={}", semver::Version::parse(v).unwrap());
Defensive patterns

Strategy: validation

Validate before calling

// Build-time guard in build.rs
let v = std::env::var("RUNNING_ASTRID_VERSION").unwrap();
semver::Version::parse(&v).expect("RUNNING_ASTRID_VERSION must be valid semver");

Type guard

fn is_semver(s: &str) -> bool { semver::Version::parse(s).is_ok() }

Try / catch

match enforce_astrid_version(&manifest) {
    Err(e) if e.to_string().contains("not valid semver") => {
        eprintln!("broken build: reinstall astrid from an official release");
    },
    other => other?,
}

Prevention

When it happens

Trigger: RUNNING_ASTRID_VERSION containing non-semver text, e.g. a git describe output like '0.6.0-3-gabc1234' with invalid prerelease syntax, a 'v' prefix ('v0.6.0'), 'dev', or an empty string baked in at compile time.

Common situations: Custom/local builds injecting raw git tags or branch names; CI builds stamping versions like '0.6.0+build meta' incorrectly; nightlies built without the version stamp at all.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/25d6a61a085ef5b9. Report an issue: GitHub.

Appendix: source

Thrown at crates/astrid-cli/src/commands/distro/validate.rs:274

    Ok(())
}

/// Enforce a manifest's `[distro].astrid-version` floor against the running CLI.
///
/// Called on the init / `distro apply` path *after* the manifest is fetched and
/// parsed but *before* any prompting or install, so a distro whose `Distro.toml`
/// (fetched from the repo `main` tip) bumps its CLI floor fails fast with an
/// actionable message instead of breaking onboarding mid-flight on an older CLI.
///
/// A manifest with no `astrid-version` floor imposes no requirement.
pub(crate) fn enforce_astrid_version(manifest: &DistroManifest) -> anyhow::Result<()> {
    let Some(req) = manifest.distro.astrid_version.as_deref() else {
        return Ok(());
    };
    let running = Version::parse(RUNNING_ASTRID_VERSION).map_err(|e| {
        // The binary's own version should always be valid semver; if it isn't,
        // that's a build-time defect, not a distro problem.
        anyhow::anyhow!(
            "running astrid version {RUNNING_ASTRID_VERSION:?} is not valid semver: {e}"
        )
    })?;
    distro_astrid_version_satisfied(req, &running)
}

/// Decide whether the running CLI `running` satisfies a distro's
/// `[distro].astrid-version` requirement `req`.
///
/// Pure (no fetch, no env) so it is unit-testable in isolation.
///
/// **Prerelease policy.** By default `semver::VersionReq::matches` refuses a
/// prerelease running version (e.g. `0.6.0-dev.3` does *not* satisfy `>=0.6.0`),
/// which would falsely reject a locally-built / dev CLI that is, by release
/// triple, at or above the floor. That is the classic semver footgun. When the
/// requirement is a plain release floor we compare on the **release triple
/// only** — the running version's `(major, minor, patch)` with the prerelease
/// and build metadata stripped — so a dev build of a sufficiently-new astrid is

View on GitHub (pinned to affd8760f4)