PRQL/prql · error

Could not parse prqlc version number

Error message

Could not parse prqlc version number {cargo_version}\n{e}

What it means

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.

Solutions

  1. Ensure Cargo.toml contains a valid semver version (major.minor.patch)
  2. Build from a git checkout with tags present (`git fetch --tags`), so git describe yields a parseable version
  3. 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
  4. Check build logs for the preceding 'Could not parse git version number' info message to see what git_version was

Example fix

# before (Cargo.toml)
version = "0.13-dev"
# after
version = "0.13.0"
Defensive patterns

Strategy: validation

Validate before calling

# Check that a parseable version exists before building
cargo metadata --no-deps | jq -r '.packages[] | select(.name=="prqlc") | .version' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+'

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.

Related errors


AI-assisted analysis of PRQL/prql@e164e249b9 (2026-09-09). Data as JSON: /api/errors/b618ea111e81c221. Report an issue: GitHub.

Appendix: source

Thrown at prqlc/prqlc/src/lib.rs:160

pub fn compiler_version() -> Version {
    if let Ok(prql_version_override) = std::env::var("PRQL_VERSION_OVERRIDE") {
        return Version::parse(&prql_version_override).unwrap_or_else(|e| {
            panic!("Could not parse PRQL version {prql_version_override}\n{e}")
        });
    };

    static COMPILER_VERSION: OnceLock<Version> = OnceLock::new();
    COMPILER_VERSION
        .get_or_init(|| {
            let git_version = env!("VERGEN_GIT_DESCRIBE");
            let cargo_version = env!("CARGO_PKG_VERSION");
            Version::parse(git_version)
                .or_else(|e| {
                    log::info!("Could not parse git version number {git_version}\n{e}");
                    Version::parse(cargo_version)
                })
                .unwrap_or_else(|e| {
                    panic!("Could not parse prqlc version number {cargo_version}\n{e}")
                })
        })
        .clone()
}

/// Compile a PRQL string into a SQL string.
///
/// This is a wrapper for:
/// - [prql_to_pl] — Build PL AST from a PRQL string
/// - [pl_to_rq] — Finds variable references, validates functions calls,
///   determines frames and converts PL to RQ.
/// - [rq_to_sql] — Convert RQ AST into an SQL string.
/// # Example
/// Use the prql compiler to convert a PRQL string to SQLite dialect
///
/// ```
/// use prqlc::{compile, Options, Target, sql::Dialect};
///

View on GitHub (pinned to e164e249b9)