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.
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.95Common 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
- Read the wasm-bindgen version from Cargo.lock.
- Install the CLI pinned to that exact version.
- Re-run the build so both schema versions match.
# match the version that Cargo.lock locks for the crate
cargo install -f wasm-bindgen-cli --version 0.2.92Let 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.
- 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.