Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm-bindgen failed to build : version mismatch #169

Closed
afidegnum opened this issue Aug 3, 2022 · 15 comments
Closed

wasm-bindgen failed to build : version mismatch #169

afidegnum opened this issue Aug 3, 2022 · 15 comments
Labels
A-cli Area: command line interface C-bug Category: bug tribble-reported This issue was reported through Tribble.

Comments

@afidegnum
Copy link
Contributor

This issue is reporting a bug in the code of Perseus. Details of the scope will be available in issue labels.
The author described their issue as follows:

wasm-bindgen failed to build: version mismatch

The steps to reproduce this issue are as follows:

while testing the example at: https://github.com/arctic-hen7/perseus/tree/main/examples/demos/auth
I had an error while calling perseus serve
Trying to upgrade/downgrade web-sys or wasm-bindgen didnt' help.
The error seems to happen from the global_state while trying to use web_sys

The details of the log report is as follow

 perseus serve
  [1/4] 🔨 Generating your app...✅
  [2/4] 🏗️  Building your app to Wasm...❌
  [3/4] 📡 Building server...✅
error:

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.82
     this binary schema version: 0.2.81 (062aa5f70)

Currently the bindgen format is unstable enough that these two schema versions
must exactly match. You can accomplish this by either updating the wasm-bindgen
dependency or this binary.

You should be able to update the wasm-bindgen dependency with:

    cargo update -p wasm-bindgen

or you can update the binary with

    cargo install -f wasm-bindgen-cli

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!

A minimum reproducible example is available at <>.

  • Hydration-related: false
  • The author is willing to attempt a fix: false
Tribble internal data

dHJpYmJsZS1yZXBvcnRlZCxDLWJ1ZyxBLWNsaQ==

@github-actions github-actions bot added A-cli Area: command line interface C-bug Category: bug tribble-reported This issue was reported through Tribble. labels Aug 3, 2022
@arctic-hen7
Copy link
Member

Try setting wasm-bindgen as a dependency with version 0.2.82 in your Cargo.toml, then run perseus clean and perseus build. That should fix the version mismatch. I'll be sure to add this to the docs.

@afidegnum
Copy link
Contributor Author

I followed the procedure, the error persists after perseus clean and build, I specified either wasm-bindgen = "0.2.81" or wasm-bindgen = "0.2.82"

@afidegnum
Copy link
Contributor Author

afidegnum commented Aug 8, 2022

Here is my current manifest

[package]
name = "authweb"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
perseus = { version = "0.4.0-beta.5", features = ["hydrate"] }
sycamore = "=0.8.0-beta.7"
serde = { version = "1", features = ["derive"] }
serde_json = "1.0.81"
lazy_static = "1.4.0"
derive_more = "0.99.17"
futures = "0.3.21"
chrono = "0.4.19"
walkdir = "2.3.2"
dotenv = "0.15.0"
config = "0.13.1"
web-sys = { version = "0.3", features = [ "Storage" ] }
wasm-bindgen = "0.2.82"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1", features = [ "macros", "rt", "rt-multi-thread" ] }
perseus-actix-web = { version = "=0.4.0-beta.5", features = [ "dflt-server" ] }
reqwest = "0.11"

[target.'cfg(target_arch = "wasm32")'.dependencies]
# web-sys = { version = "0.3", features = [ "Storage" ] }
# wasm-bindgen = "0.2.82"
reqwasm = "0.4"
rexie = "0.4.2"

@arctic-hen7
Copy link
Member

What does perseus --version give you? Also, what OS are you running?

@afidegnum
Copy link
Contributor Author

perseus-cli 0.4.0-beta.5

I'm using Debian GNU/Linux 10 (buster) running on wsl2

@arctic-hen7
Copy link
Member

perseus build --wasm-bindgen-version 0.2.82 should fix this, for you and future users (substitute the latest version). Be warned that something like this will happen every time there's a new wasm-bindgen version released unless you pin your dependency to a specific version (e.g. 0.2.81), since Cargo might automatically update, leaving the installed CLI (installed behind the scenes for you) outdated.

@arctic-hen7
Copy link
Member

arctic-hen7 commented Aug 9, 2022

I'll update the docs to reflect this requirement. Unfortunately I don't see any way of getting around pinning the version explicitly in Cargo.toml.

@lukechu10
Copy link
Contributor

The way trunk does this, and which seems to work pretty well, is to just get the wasm-bindgen version from the Cargo.toml and automatically install the right wasm-bindgen version. Might be worth looking at their code and doing something similar.

@arctic-hen7
Copy link
Member

Yes, that's on my to-do list! I wanted to get a functional system for installing the tools in the first place out, and then that's very much on the roadmap.

@afidegnum
Copy link
Contributor Author

Thanks,

@afidegnum
Copy link
Contributor Author

if I understand, while wasm-bindgen version is in manifest, I still have to execute perseus build --wasm-bindgen-version 0.2.82. Do we build this before running perseus serve ?

@arctic-hen7
Copy link
Member

No no, you only have to do this once. Behind the scenes, Perseus installs things like wasm-bindgen in a system-wide cache. After running that command, you have the new version installed, and you don't have to worry about it again. In deployment, the tools will be correctly installed automatically in most setups.

@afidegnum
Copy link
Contributor Author

ok, thanks

arctic-hen7 added a commit that referenced this issue Aug 20, 2022
This should prevent future inconveniences with updated to tools like
`wasm-bindgen`.
Addresses reccomendations from #169.
@arctic-hen7
Copy link
Member

I've now built in support for automatically detecting the versions of tools from Cargo.lock, as wasm-pack does, which should avoid issues like this cropping up in the future. (More accurately, if you modify your Cargo.toml, this issue might appear in some cases, but a re-run of the command will have fixed it already.)

@afidegnum
Copy link
Contributor Author

Thanks a lot for the great works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cli Area: command line interface C-bug Category: bug tribble-reported This issue was reported through Tribble.
Projects
None yet
Development

No branches or pull requests

3 participants