rustwasm-bindgenrust-axumleptos

leptos with axum: Issue with wasm-bindgen versions


I am just getting started with Rust and Leptos, so I'm also quite new to the whole rust / cargo ecosystem.

I was following the leptos tutorial to setup a new leptos project using axum. When I tried starting the project with

cargo leptos watch

I ran into the following issue:

Error: at `/Users/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-leptos-0.1.9/src/compile/front.rs:46:30`

Caused by:
    0: at `/Users/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-leptos-0.1.9/src/compile/front.rs:111:10`
    1: 
       
       it looks like the Rust project used to create this wasm file was linked against
       version of wasm-bindgen that uses a different bindgen format than this binary:
       
         rust wasm file schema version: 0.2.84
            this binary schema version: 0.2.86
       
       Currently the bindgen format is unstable enough that these two schema versions
       must exactly match. You can accomplish this by either updating this binary or 
       the wasm-bindgen dependency in the Rust project.
       
       You should be able to update the wasm-bindgen dependency with:
       
           cargo update -p wasm-bindgen --precise 0.2.86
       
       don't forget to recompile your wasm file! Alternatively, you can update the 
       binary with:
       
           cargo install -f wasm-bindgen-cli --version 0.2.84
       
       if this warning fails to go away though and you're not sure what to do feel free
       to open an issue at https://github.com/rustwasm/wasm-bindgen/issues!

I tried both suggested solutions. The first one gives me

    Updating crates.io index
error: failed to select a version for the requirement `wasm-bindgen = "=0.2.84"`
candidate versions found which didn't match: 0.2.86
location searched: crates.io index
required by package `start-axum v0.1.0 (...)`
perhaps a crate was updated and forgotten to be re-vendored?

The second option gives me no errors, but it doesn't resolve the initial problem.

Anyone had this issue before?


Solution

  • Just changed the was-bindgen in Cargo.toml to wasm-bindgen = "=0.2.86" and now it works - as also suggested by @kmdreko.

    cargo update does not seem to force update packages, if they are defined with an exact version (=)