Skip to content
Latchkey

wasm-bindgen "schema version mismatch" between CLI and crate in CI

The wasm-bindgen CLI embeds a schema version that must match the wasm-bindgen crate compiled into your module. When CI installs a CLI version that differs from the crate in Cargo.lock, post-processing aborts.

What this error means

wasm-bindgen (often run by wasm-pack or trunk) fails with "it looks like the Rust project used to create this wasm file was linked against a different version of wasm-bindgen than this binary" and prints two schema versions.

wasm-bindgen
Error: it looks like the Rust project used to create this wasm file was linked against
a different version of wasm-bindgen than this binary:

  rust wasm file schema version: 0.2.92
     this binary schema version: 0.2.95

Common causes

CLI installed independently of the crate version

CI ran cargo install wasm-bindgen-cli (or a cached binary) that resolved to a newer release than the wasm-bindgen crate pinned in Cargo.lock.

A cached or system wasm-bindgen-cli is stale

A previously cached CLI binary no longer matches the crate after a dependency bump, so the embedded schema versions diverge.

How to fix it

Install the CLI at the exact crate version

  1. Read the wasm-bindgen version from Cargo.lock.
  2. Install the CLI pinned to that exact version.
  3. Re-run the build so both schema versions match.
Terminal
# match the version that Cargo.lock locks for the crate
cargo install -f wasm-bindgen-cli --version 0.2.92

Let a version-aware action handle it

Tools that read the lock and fetch the matching CLI keep the two in sync without a manual pin.

.github/workflows/ci.yml
- uses: jetli/wasm-bindgen-action@v0.2.0
  with:
    version: 'latest'

How to prevent it

  • Pin the CLI version to the crate version from Cargo.lock.
  • Invalidate any wasm-bindgen-cli cache key on dependency changes.
  • Upgrade the crate and the CLI together in one commit.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →