astrid-runtime/astrid · error

distro.astrid-version {req:?} is not a valid requirement: {e

Error message

distro.astrid-version {req:?} is not a valid requirement: {e}

What it means

distro_astrid_version_satisfied parses the manifest's [distro].astrid-version string as a semver::VersionReq before evaluating it against the running version. This error means the requirement string itself is not a valid semver requirement — it never reaches any comparison logic.

Source

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

/// **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
/// accepted, while still rejecting a CLI whose release triple genuinely falls
/// below the floor. A clean (non-prerelease) running version compares unchanged.
///
/// **When the requirement itself names a prerelease** (e.g. `>=0.6.0-rc.3`) the
/// operator is deliberately gating on a specific prerelease, so triple-stripping
/// the running version would *over-accept*: `0.6.0-rc.2` would be lifted to
/// `0.6.0` and wrongly satisfy `>=0.6.0-rc.3`. In that case we drop the
/// dev-build convenience and compare the running version **as-is** under exact
/// semver semantics, so prerelease ordering (`rc.2 < rc.3`) is honoured.
pub(crate) fn distro_astrid_version_satisfied(req: &str, running: &Version) -> anyhow::Result<()> {
    let version_req = VersionReq::parse(req).map_err(|e| {
        anyhow::anyhow!("distro.astrid-version {req:?} is not a valid requirement: {e}")
    })?;

    // If any comparator in the requirement carries a prerelease, the operator
    // is gating on an exact prerelease — honour real semver semantics (no
    // triple-strip) so a lower prerelease of the same triple is not lifted past
    // the floor. Otherwise apply the dev-build footgun fix below.
    let req_names_prerelease = version_req.comparators.iter().any(|c| !c.pre.is_empty());
    if req_names_prerelease {
        if version_req.matches(running) {
            return Ok(());
        }
        return Err(AstridVersionTooOld {
            req: req.to_string(),
            running: running.to_string(),
        }
        .into());
    }

View on GitHub (pinned to affd8760f4)

Solutions

  1. Rewrite astrid-version using semver requirement syntax the crate accepts (e.g. '>=0.6.0', '0.6.0', '>=0.5, <0.7').
  2. Drop npm-specific operators (~, ^, x-ranges) not supported by the semver crate.
  3. Test the requirement string with a quick `VersionReq::parse` check or cargo script before committing the manifest.

Example fix

# before (Distro.toml)
[distro]
astrid-version = "^0.6.0"
# after
[distro]
astrid-version = ">=0.6.0"
Defensive patterns

Strategy: validation

Validate before calling

fn is_valid_semver_req(s: &str) -> bool { semver::VersionReq::parse(s).is_ok() }
// check the [distro].astrid-version string before publishing

Try / catch

match enforce_astrid_version(&manifest) {
    Err(e) if e.to_string().contains("not a valid requirement") => {
        eprintln!("fix astrid-version syntax in Distro.toml: {e}");
    },
    other => other?,
}

Prevention

When it happens

Trigger: A Distro.toml declaring astrid-version values like '>= 0.6' with bad spacing variants the parser rejects, '0.6.x' wildcard syntax not accepted, '^0.6.0' if caret is unsupported, multiple comparators with a typo ('>=0.5, <0.7' with wrong separator), or an empty string.

Common situations: Authors copying npm-style ranges ('~0.6.2', 'x-bounds') that the Rust semver crate rejects; typos like '>=o.6.0'; listing two versions separated by spaces incorrectly.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


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