{"record":{"id":"25d6a61a085ef5b9","repo":"astrid-runtime/astrid","slug":"running-astrid-version-running-astrid-version","errorCode":null,"errorMessage":"running astrid version {RUNNING_ASTRID_VERSION:?} is not valid semver: {e}","messagePattern":"running astrid version (.+?) is not valid semver: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/distro/validate.rs","lineNumber":274,"sourceCode":"    Ok(())\n}\n\n/// Enforce a manifest's `[distro].astrid-version` floor against the running CLI.\n///\n/// Called on the init / `distro apply` path *after* the manifest is fetched and\n/// parsed but *before* any prompting or install, so a distro whose `Distro.toml`\n/// (fetched from the repo `main` tip) bumps its CLI floor fails fast with an\n/// actionable message instead of breaking onboarding mid-flight on an older CLI.\n///\n/// A manifest with no `astrid-version` floor imposes no requirement.\npub(crate) fn enforce_astrid_version(manifest: &DistroManifest) -> anyhow::Result<()> {\n    let Some(req) = manifest.distro.astrid_version.as_deref() else {\n        return Ok(());\n    };\n    let running = Version::parse(RUNNING_ASTRID_VERSION).map_err(|e| {\n        // The binary's own version should always be valid semver; if it isn't,\n        // that's a build-time defect, not a distro problem.\n        anyhow::anyhow!(\n            \"running astrid version {RUNNING_ASTRID_VERSION:?} is not valid semver: {e}\"\n        )\n    })?;\n    distro_astrid_version_satisfied(req, &running)\n}\n\n/// Decide whether the running CLI `running` satisfies a distro's\n/// `[distro].astrid-version` requirement `req`.\n///\n/// Pure (no fetch, no env) so it is unit-testable in isolation.\n///\n/// **Prerelease policy.** By default `semver::VersionReq::matches` refuses a\n/// prerelease running version (e.g. `0.6.0-dev.3` does *not* satisfy `>=0.6.0`),\n/// which would falsely reject a locally-built / dev CLI that is, by release\n/// triple, at or above the floor. That is the classic semver footgun. When the\n/// requirement is a plain release floor we compare on the **release triple\n/// only** — the running version's `(major, minor, patch)` with the prerelease\n/// and build metadata stripped — so a dev build of a sufficiently-new astrid is","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/distro/validate.rs#L256-L292","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Rebuild/reinstall astrid from an official release so RUNNING_ASTRID_VERSION is a clean semver triple.","Fix the build script that stamps the version to emit valid semver (strip 'v' prefix, convert git-describe to valid prerelease/build metadata).","Check `astrid --version` output and compare against semver.org rules to see what is malformed."],"exampleFix":"// before: build.rs\nprintln!(\"cargo:rustc-env=RUNNING_ASTRID_VERSION={}\", git_describe); // \"0.6.0-3-gabc\"\n// after\nlet v = git_describe.trim_start_matches('v');\nlet v = v.replace(\"-g\", \"+g\"); // \"0.6.0-3+gabc\" -> precompute a valid semver instead\nprintln!(\"cargo:rustc-env=RUNNING_ASTRID_VERSION={}\", semver::Version::parse(v).unwrap());","handlingStrategy":"validation","validationCode":"// Build-time guard in build.rs\nlet v = std::env::var(\"RUNNING_ASTRID_VERSION\").unwrap();\nsemver::Version::parse(&v).expect(\"RUNNING_ASTRID_VERSION must be valid semver\");","typeGuard":"fn is_semver(s: &str) -> bool { semver::Version::parse(s).is_ok() }","tryCatchPattern":"match enforce_astrid_version(&manifest) {\n    Err(e) if e.to_string().contains(\"not valid semver\") => {\n        eprintln!(\"broken build: reinstall astrid from an official release\");\n    },\n    other => other?,\n}","preventionTips":["Install astrid from official releases, not ad-hoc local builds.","Make build.rs assert the stamped version parses as semver.","Run `astrid --version` and sanity-check it after custom builds."],"tags":["semver","build","internal","versioning"],"backgroundTag":"internal-invariant-violation","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}