Wasm32-unknown-unknown target is not supported by default, you may need to enable the "js" feature

Dear all

Almost out of nowhere a new error is occurring when I call

dfx build canister_backend

The command leads to

cargo build --target wasm32-unknown-unknown --release -p canister_backend --locked

which finally results in some new and weird compilations:

   Compiling getrandom v0.2.8
   Compiling tokio v1.24.1
   Compiling mio v0.8.5
   Compiling want v0.3.0
   Compiling socket2 v0.4.7
   Compiling rustls-native-certs v0.6.2
   Compiling async-trait v0.1.61

My project does not rely on packages like getrandom nor mio nor socket.

Not surprising, it leads to dozens of errors, the top one showing:

error: the wasm32-unknown-unknown target is not supported by default, you may need to enable the "js" feature.

I guess that somehow the cargo target might have changed?

Happy to get some clues :slight_smile:

BR and thanks

Not a Rust expert but I guess so. Probably one of your dependencies has fetched a new minor or major update for an indirect dependencies. Did anything changed in one of your Cargo.toml or Cargo.lock file recently? Or did you add a new dependency?

I remember having once such error message when I tried to use a crate that was not compatible.

Hi peterparker

That was exactly it! I briefly had a dependency which was not compatible. Even though the Cargo.toml was clean, the Cargo.lock was not, and this caused the issue.

Solved now!

Thank you very much.

Cheers

Ah super, happy to hear it worked out and good to know!