leptos with axum: wasm-bindgen版本问题

huangapple go评论66阅读模式
英文:

leptos with axum: Issue with wasm-bindgen versions

问题

我刚刚开始学习Rust和Leptos,所以对整个Rust / Cargo生态系统也相当新奇。

我正在按照leptos教程来设置一个新的leptos项目,使用axum。当我尝试用以下命令启动项目时:

cargo leptos watch

我遇到了以下问题:

错误:位于`/Users/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-leptos-0.1.9/src/compile/front.rs:46:30`

原因是:
    0:位于`/Users/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-leptos-0.1.9/src/compile/front.rs:111:10`
    1: 

       看起来用于创建此wasm文件的Rust项目与此二进制文件使用的wasm-bindgen版本绑定格式不同:

         Rust wasm文件模式版本:0.2.84
            此二进制文件模式版本:0.2.86

       目前,绑定格式不稳定,以至于这两个模式版本必须完全匹配。您可以通过更新此二进制文件或Rust项目中的wasm-bindgen依赖项来实现这一点。

       您应该能够使用以下命令更新wasm-bindgen依赖项:

           cargo update -p wasm-bindgen --precise 0.2.86

       不要忘记重新编译您的wasm文件!或者,您可以使用以下命令更新二进制文件:

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

       如果此警告仍未消失,并且您不确定该怎么做,请随时在https://github.com/rustwasm/wasm-bindgen/issues上报告问题!

我尝试了建议的两种解决方案。第一种给我带来了以下错误:

    更新crates.io索引
错误:无法选择要求`wasm-bindgen = "0.2.84"`的版本
找到的候选版本与之不匹配:0.2.86
搜索位置:crates.io索引
`start-axum v0.1.0 (...)`包需要
也许某个crate已经更新,但忘记重新生成了吗?

第二个选项没有给我带来错误,但没有解决最初的问题。

有人之前遇到过这个问题吗?

英文:

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?

答案1

得分: 0

只需将Cargo.toml中的was-bindgen更改为wasm-bindgen = "0.2.86",现在可以正常工作 - 如@kmdreko建议的那样。

cargo update似乎不会强制更新包,如果它们被定义为精确版本(=)。

英文:

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 (=)

huangapple
  • 本文由 发表于 2023年6月12日 06:25:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76452749.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定