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 version confusion #3411

Open
brianmay opened this issue Dec 19, 2024 · 4 comments
Open

wasm-bindgen version confusion #3411

brianmay opened this issue Dec 19, 2024 · 4 comments

Comments

@brianmay
Copy link

brianmay commented Dec 19, 2024

Problem

After creating new full stack project with dioxus cli 6.1, and attempting to build it, I get the following error:

08:25:39 [dev] Build failed: Other(Failed to write main executable

Caused by:
    0: Failed to generate wasm-bindgen bindings
    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.99
            this binary schema version: 0.2.97

       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.97

       don't forget to recompile your Wasm file! Alternatively, you can update the
       binary with:

           cargo install -f wasm-bindgen-cli --version 0.2.99

       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!
       )

So according to this I have two options:

  1. I should upgrade wasm-bindgen-cli binaries to version 0.2.99.

    This doesn't work. I already have 0.2.99 installed:

    # wasm-bindgen -V
    wasm-bindgen 0.2.99

    The problem is that dioxus cli is directly linked into 0.2.97, and I can't change this at run time.

    https://github.com/DioxusLabs/dioxus/blob/v0.6/Cargo.lock#L14886-L14895

  2. Downgrade the project to use version 0.2.97 not 0.2.99.

    This also doesn't work,

    # cargo update -p wasm-bindgen --precise 0.2.97
        Updating crates.io index
    error: failed to select a version for the requirement `wasm-bindgen = "^0.2.99"`
    candidate versions found which didn't match: 0.2.97
    location searched: crates.io index
    required by package `dioxus-cli-config v0.6.1`
        ... which satisfies dependency `dioxus-cli-config = "^0.6.0"` (locked to 0.6.1) of package `dioxus v0.6.0`
        ... which satisfies dependency `dioxus = "=0.6.0"` (locked to 0.6.0) of package `dioxus-fs v0.1.0 (/home/brian/tree/3rdparty/dioxus-fs)`

Originally I thought this was a nixos specific issue, so I reported it there, but on closer inspection it looks like a dioxus bug.

Steps To Reproduce

Steps to reproduce the behavior:

  • Create new dx fulls stack project with "dx new".
  • Try to build it with dx serve --platform web

Expected behavior

This operation should work.

Environment:

  • Dioxus version: 0.6
  • Rust version: 1.83.0
  • OS info: Linux
  • App platform: web

Questionnaire

@brianmay
Copy link
Author

brianmay commented Dec 19, 2024

Forgot to mention, I changed the dioxus dependency to:

dioxus = { version = "=0.6.0", features = ["router", "fullstack"] }

In order to work around #3391

But the output above indicates it is pulling in dioxus-cli-config v0.6.1, which looks wrong. Lets try to fix that:

# cargo update -p dioxus-cli-config --precise 0.6.0
    Updating crates.io index
error: failed to select a version for the requirement `dioxus-cli-config = "^0.6.1"`
candidate versions found which didn't match: 0.6.0
location searched: crates.io index
required by package `dioxus-desktop v0.6.1`
    ... which satisfies dependency `dioxus-desktop = "^0.6.0"` (locked to 0.6.1) of package `dioxus v0.6.0`
    ... which satisfies dependency `dioxus = "=0.6.0"` (locked to 0.6.0) of package `dioxus-fs v0.1.0 (/home/brian/tree/3rdparty/dioxus-fs)`

Dependency hell!

Dependencies need to be upgraded in exactly the right order.

I think something like:

# cargo update -p dioxus-fullstack  --precise 0.6.0
    Updating crates.io index
 Downgrading dioxus-fullstack v0.6.1 -> v0.6.0
note: pass `--verbose` to see 12 unchanged dependencies behind latest

# cargo update -p dioxus-mobile  --precise 0.6.0
    Updating crates.io index
 Downgrading dioxus-mobile v0.6.1 -> v0.6.0
note: pass `--verbose` to see 13 unchanged dependencies behind latest

# cargo update -p dioxus-desktop  --precise 0.6.0
    Updating crates.io index
 Downgrading dioxus-desktop v0.6.1 -> v0.6.0
note: pass `--verbose` to see 14 unchanged dependencies behind latest

# cargo update -p dioxus-logger --precise 0.6.0
    Updating crates.io index
 Downgrading dioxus-logger v0.6.1 -> v0.6.0
note: pass `--verbose` to see 15 unchanged dependencies behind latest

# cargo update -p dioxus-router --precise 0.6.0
    Updating crates.io index
 Downgrading dioxus-router v0.6.1 -> v0.6.0
note: pass `--verbose` to see 16 unchanged dependencies behind latest

# cargo update -p dioxus-web --precise 0.6.0
    Updating crates.io index
 Downgrading dioxus-web v0.6.1 -> v0.6.0
note: pass `--verbose` to see 17 unchanged dependencies behind latest

# cargo update -p manganis --precise 0.6.0
    Updating crates.io index
 Downgrading manganis v0.6.1 -> v0.6.0
note: pass `--verbose` to see 18 unchanged dependencies behind latest

# cargo update -p manganis-macro --precise 0.6.0
    Updating crates.io index
 Downgrading manganis-macro v0.6.1 -> v0.6.0
note: pass `--verbose` to see 19 unchanged dependencies behind latest

# cargo update -p manganis-core --precise 0.6.0
    Updating crates.io index
 Downgrading manganis-core v0.6.1 -> v0.6.0
note: pass `--verbose` to see 20 unchanged dependencies behind latest

# cargo update -p dioxus-cli-config --precise 0.6.0
    Updating crates.io index
 Downgrading dioxus-cli-config v0.6.1 -> v0.6.0
note: pass `--verbose` to see 21 unchanged dependencies behind latest

Out of time, not tested yet, but I expect this might work now

@brianmay
Copy link
Author

Sorry, missed one, how to deal with this not so obvious.

# cargo update -p wasm-bindgen --precise 0.2.97
    Updating crates.io index
error: failed to select a version for the requirement `wasm-bindgen = "=0.2.99"`
candidate versions found which didn't match: 0.2.97
location searched: crates.io index
required by package `web-sys v0.3.76`
    ... which satisfies dependency `web-sys = "^0.3.61"` (locked to 0.3.76) of package `dioxus-fullstack v0.6.0`
    ... which satisfies dependency `dioxus-fullstack = "^0.6.0"` (locked to 0.6.0) of package `dioxus v0.6.0`
    ... which satisfies dependency `dioxus = "=0.6.0"` (locked to 0.6.0) of package `dioxus-fs v0.1.0 (/home/brian/tree/3rdparty/dioxus-fs)`

@Nejat
Copy link

Nejat commented Dec 22, 2024

Is this happening on a Mac?
I had a similar issue which I was able to resolve.
My issue was Rustup was installed from brew instead of the official way as described with Installing Rust.
After uninstalling with the following commands, I reinstalled everything and it all works for me now.
That being said my issue was similar but not exactly the same as yours, hope this helps. see #3418

Steps (on MacOS)

  • cargo install --list | grep : | cut -d' ' -f1 -f3 list all your installed cargo plugins, you will have reinstall them
  • rustup show list your targets and toolchains, you will have to reinstall them too
  • rustup self uninstall
  • brew uninstall rust
  • curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

@brianmay
Copy link
Author

brianmay commented Dec 22, 2024

No, this is Linux. The problem was mentioned here:

#3402 (reply in thread)

The wasm-bindgen folks recently started pinning the version of wasm-bindgen indirectly, meaning our CLI uses a wasm-bindgen version that's "frozen in time" and can never work with a rust project that runs "cargo update".

rustwasm/wasm-bindgen#4304 (comment)

This forced us to add a feature that downloads wasm-bindgen from the binary source to match the schema version in the wasm output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants