Cargo concordium build error

Getting this error when i run

cargo concordium build --schema-embed --out dist/staking_dapp.module.wasm.v1 --schema-out dist/schema.bin

mac@Kenzie contract % cargo concordium build --schema-embed --out dist/staking_dapp.module.wasm.v1 --schema-out dist/schema.bin
   Compiling proc-macro2 v1.0.89
   Compiling hashbrown v0.11.2
   Compiling base64 v0.21.7
   Compiling fnv v1.0.7
error[E0463]: can't find crate for `std`
  |
  = note: the `wasm32-unknown-unknown` target may not be installed
  = help: consider downloading the target with `rustup target add wasm32-unknown-unknown`

For more information about this error, try `rustc --explain E0463`.
error: could not compile `fnv` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `base64` (lib) due to 1 previous error
error[E0463]: can't find crate for `core`
  |
  = note: the `wasm32-unknown-unknown` target may not be installed
  = help: consider downloading the target with `rustup target add wasm32-unknown-unknown`

error: could not compile `hashbrown` (lib) due to 1 previous error
Error: Could not build smart contract.

Caused by:
    0: Could not build module schema.
    1: Compilation failed.```

Hi there

First, make sure that wasm32-unknown-unknown is installed as the error suggest:

rustup target add wasm32-unknown-unknown

Assuming that you already did this, and still get the error, then it might be missing rust-src.
This has happened to me in the past, when changing the toolchain.

rustup component add rust-src

If you still get the same error, maybe you could try compiling without targeting wasm32-unknown-unknown and see whether you get the same error:

cargo build

wasm32-unknown-unknown and rust-src are available,
running cargo build, builds just fine

but running cargo concordium build, is an issue…

i even uninstalled and reinstalled rustup and cargo-concordium and still got the same issue.

does it have anything to do with running node?

Had to downgrade everything to

rustc version 1.79.0
cargo-concordium version 3.3.0

latest versions :
rustc version 1.82.0
cargo-concordium version 4.0.0

didnt seem compartible as i as getting error…

could not validate resulting smart contract module as a V1 contract.

could not validate resulting smart contract module as a V1 contract.

Yes, this is a known issue with rustc 1.82, downgrading to 1.81 should be enough.

Starting from rustc 1.82, the compiler changed details for the produced WebAssembly, which are not compatible with our smart contract execution in the blockchain.
Since the fix require an update of the protocol it will take some time before it lands, so for now the best option is to use 1.81.