{"record":{"id":"b618ea111e81c221","repo":"PRQL/prql","slug":"could-not-parse-prqlc-version-number-cargo-versio","errorCode":null,"errorMessage":"Could not parse prqlc version number {cargo_version}\\n{e}","messagePattern":"Could not parse prqlc version number (.+?)\\\\n(.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"prqlc/prqlc/src/lib.rs","lineNumber":160,"sourceCode":"pub 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()\n}\n\n/// Compile a PRQL string into a SQL string.\n///\n/// This is a wrapper for:\n/// - [prql_to_pl] — Build PL AST from a PRQL string\n/// - [pl_to_rq] — Finds variable references, validates functions calls,\n///   determines frames and converts PL to RQ.\n/// - [rq_to_sql] — Convert RQ AST into an SQL string.\n/// # Example\n/// Use the prql compiler to convert a PRQL string to SQLite dialect\n///\n/// ```\n/// use prqlc::{compile, Options, Target, sql::Dialect};\n///","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/PRQL/prql/blob/e164e249b99485890036eb60f57c37520379b240/prqlc/prqlc/src/lib.rs#L142-L178","documentation":"compiler_version() derives the version from `git describe --tags`, falling back to the cargo manifest version. If neither parses as a valid semver (the fallback parse also failed), it panics. Normally unreachable, but it can fire when git metadata is absent or malformed and Cargo.toml carries a non-semver version.","triggerScenarios":"Building in a directory without git tags/history (e.g. a source tarball or shallow export) so git_version is empty/unparseable, AND the cargo version in Cargo.toml also fails Version::parse (e.g. a pre-release string the semver parser rejects or a placeholder).","commonSituations":"Building from an extracted release tarball, a crates.io vendored copy with altered manifest, or a downstream fork that changed the version string in Cargo.toml to a non-semver value.","solutions":["Ensure Cargo.toml contains a valid semver version (major.minor.patch)","Build from a git checkout with tags present (`git fetch --tags`), so git describe yields a parseable version","If packaging for a distro, patch compiler_version or set a valid PRQL_VERSION_OVERRIDE instead of editing the manifest to a non-semver value","Check build logs for the preceding 'Could not parse git version number' info message to see what git_version was"],"exampleFix":"# before (Cargo.toml)\nversion = \"0.13-dev\"\n# after\nversion = \"0.13.0\"","handlingStrategy":"validation","validationCode":"# Check that a parseable version exists before building\ncargo metadata --no-deps | jq -r '.packages[] | select(.name==\"prqlc\") | .version' | grep -E '^[0-9]+\\.[0-9]+\\.[0-9]+'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep Cargo.toml versions valid semver","Build from git checkouts with tags fetched (git fetch --tags)","In distro packaging, override version via valid PRQL_VERSION_OVERRIDE rather than mangling the manifest"],"tags":["rust","semver","build"],"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"}