MoonKraken / rusty_llama

A simple ChatGPT clone in Rust on both the frontend and backend. Uses open source language models and TailwindCSS.
MIT License
398 stars 74 forks source link

Error compiling due to wasm-bindgen version #13

Open albert-queralto opened 6 months ago

albert-queralto commented 6 months ago

Hi, first of all nice work. I was wondering if you could lend me a hand, since I am experiencing and issue when trying to compile using cargo leptos watch. The error is the following:

Finished dev [unoptimized + debuginfo] target(s) in 44.24s Cargo finished cargo build --package=rusty_llama --lib --target-dir=/home/albert/Desktop/llama-rust/target/front --target=wasm32-unknown-unknown --no-default-features --features=hydrate Front compiling WASM Error: at/home/albert/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-leptos-0.2.17/src/compile/front.rs:47:30`

Caused by: 0: at /home/albert/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-leptos-0.2.17/src/compile/front.rs:122: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.89
        this binary schema version: 0.2.92

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

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

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

   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 have tried with both options, using cargo update -p wasm-bindgen --precise 0.2.92 and cargo install -f wasm-bindgen-cli --version 0.2.89, but it doesn't seem to work. Any ideas?

Thank you very much

darrenkim247 commented 5 months ago

I had a similar issue, switching the to wasm version 0.2.89 in the Cargo.toml file and disabling the metalfeature in Cargo.toml worked for me.

albert-queralto commented 5 months ago

Hi @darrenkim247, I tried your suggestion and now I am getting the following error when compiling:

error[E0433]: failed to resolve: use of undeclared crate or module `futures`
 --> src/app.rs:4:5
  |
4 | use futures::stream::SplitSink;
  |     ^^^^^^^ use of undeclared crate or module `futures`

error[E0432]: unresolved import `futures`
  --> src/app.rs:27:9
   |
27 |     use futures::{SinkExt, StreamExt};
   |         ^^^^^^^ use of undeclared crate or module `futures`

error[E0599]: no method named `split` found for struct `gloo_net::websocket::futures::WebSocket` in the current scope
    --> src/app.rs:39:45
     |
39   |         let (sender, mut recv) = connection.split();
     |                                             ^^^^^ method not found in `WebSocket`
     |
    ::: /home/albert/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.30/src/stream/stream/mod.rs:1582:8
     |
1582 |     fn split<Item>(self) -> (SplitSink<Self, Item>, SplitStream<Self>)
     |        ----- the method is available for `gloo_net::websocket::futures::WebSocket` here
     |
     = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
     |
1    + use futures_util::stream::stream::StreamExt;
     |

Some errors have detailed explanations: E0432, E0433, E0599.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `rusty_llama` (lib) due to 3 previous errors

The strange thing is that the futures module is present in the cargo.toml file. Any ideas?

darrenkim247 commented 5 months ago

You might have to remove the 'optional' tag from the futures module present in Cargo.toml. Afterwards, remove "futures" as a dependency in csr, hydrate, or ssr

PuxMath commented 1 month ago

The targets should have unique names. Consider changing their names to be unique or compiling them separately. This may become a hard error in the future; see https://github.com/rust-lang/cargo/issues/6313. Compiling rusty_llama v0.1.0 (C:\Users\ASUS ExpertBook\source\repos\rusty_llama) error[E0432]: unresolved import api::ws --> src/main.rs:3:5 | 3 | use api::ws; | ^^^^^^^ no ws in api

For more information about this error, try rustc --explain E0432. error: could not compile rusty_llama (bin "rusty_llama") due to 1 previous error

I get this error, so how I can fix it :_(

cloudwales commented 2 weeks ago

The targets should have unique names. Consider changing their names to be unique or compiling them separately. This may become a hard error in the future; see rust-lang/cargo#6313. Compiling rusty_llama v0.1.0 (C:\Users\ASUS ExpertBook\source\repos\rusty_llama) error[E0432]: unresolved import api::ws --> src/main.rs:3:5 | 3 | use api::ws; | ^^^^^^^ no ws in api

For more information about this error, try rustc --explain E0432. error: could not compile rusty_llama (bin "rusty_llama") due to 1 previous error

I get this error, so how I can fix it :_(

I got rid of this error by removing the use api::ws. I did change tokio dependancy to tokio = { version = "1", features = ["full"] } aswell so that may have done something as well, but not checked.