{"record":{"id":"b4336144dfa8c462","repo":"PRQL/prql","slug":"could-not-parse-prql-version-prql-version-overrid","errorCode":null,"errorMessage":"Could not parse PRQL version {prql_version_override}\\n{e}","messagePattern":"Could not parse PRQL version (.+?)\\\\n(.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"prqlc/prqlc/src/lib.rs","lineNumber":145,"sourceCode":"pub(crate) mod utils;\n\npub type Result<T, E = Error> = core::result::Result<T, E>;\n\n/// Get the version of the compiler. This is determined by the first of:\n/// - An optional environment variable `PRQL_VERSION_OVERRIDE`; primarily useful\n///   for internal testing.\n///   - Note that this env var is checked on every call of this function.\n///     Without checking each read, we found some internal tests were flaky. If\n///     this caused any perf issues, we could adjust the tests that rely on\n///     versions to run in a more encapsulated way (for example, use `prqlc`\n///     binary tests, which we can guarantee won't have anything call this\n///     before setting up the env var).\n/// - The version returned by `git describe --tags`\n/// - The version in the cargo manifest\npub fn compiler_version() -> Version {\n    if let Ok(prql_version_override) = std::env::var(\"PRQL_VERSION_OVERRIDE\") {\n        return Version::parse(&prql_version_override).unwrap_or_else(|e| {\n            panic!(\"Could not parse PRQL version {prql_version_override}\\n{e}\")\n        });\n    };\n\n    static COMPILER_VERSION: OnceLock<Version> = OnceLock::new();\n    COMPILER_VERSION\n        .get_or_init(|| {\n            let git_version = env!(\"VERGEN_GIT_DESCRIBE\");\n            let cargo_version = env!(\"CARGO_PKG_VERSION\");\n            Version::parse(git_version)\n                .or_else(|e| {\n                    log::info!(\"Could not parse git version number {git_version}\\n{e}\");\n                    Version::parse(cargo_version)\n                })\n                .unwrap_or_else(|e| {\n                    panic!(\"Could not parse prqlc version number {cargo_version}\\n{e}\")\n                })\n        })\n        .clone()","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/PRQL/prql/blob/e164e249b99485890036eb60f57c37520379b240/prqlc/prqlc/src/lib.rs#L127-L163","documentation":"compiler_version() reads the PRQL_VERSION_OVERRIDE env var and parses it as a semantic version to allow release tooling to override the reported compiler version. If the env var is set but is not a valid semver string, it panics with this message including the parse error. This is deliberately a hard failure so builds don't silently report a bogus version.","triggerScenarios":"Setting PRQL_VERSION_OVERRIDE to a value that fails Version::parse — e.g. missing patch segment (\"v1.0\" with the 'v', \"1.2.3.4\", non-numeric parts, trailing junk).","commonSituations":"CI release scripts exporting the var with a git tag like \"v0.13.0\" (leading 'v' is not semver), typos in the override, or a stale export in a shell profile.","solutions":["Set PRQL_VERSION_OVERRIDE to a valid semver string, e.g. 0.13.0 without a leading 'v'","Unset the env var entirely (unset PRQL_VERSION_OVERRIDE) to fall back to git describe / cargo manifest version","Check the CI/release script that exports the var and strip prefixes or suffixes before exporting","Validate locally: parse the intended value with the semver crate or a semver linter before exporting"],"exampleFix":"// before\nexport PRQL_VERSION_OVERRIDE=v0.13.0\n// after\nexport PRQL_VERSION_OVERRIDE=0.13.0","handlingStrategy":"validation","validationCode":"# Validate the override before exporting\n[[ \"$PRQL_VERSION_OVERRIDE\" =~ ^[0-9]+\\.[0-9]+\\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] || unset PRQL_VERSION_OVERRIDE","typeGuard":null,"tryCatchPattern":"// Not catchable (panic). Avoid by validating env var:\nlet override = std::env::var(\"PRQL_VERSION_OVERRIDE\").ok();\nif let Some(v) = override { if Version::parse(&v).is_err() { eprintln!(\"bad override\"); } }","preventionTips":["Never include a leading 'v' in PRQL_VERSION_OVERRIDE","Use full major.minor.patch semver in release scripts","Unset the variable when not doing release builds"],"tags":["rust","semver","env-var"],"backgroundTag":"invalid-env-var-value","analyzedSha":"e164e249b99485890036eb60f57c37520379b240","analyzedAt":"2026-09-09T12:18:38.727Z","contentChangedAt":"2026-09-09T12:18:38.727Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}