second-state / wasmedge-nodejs-starter

A template project to run Rust functions in Node.js through the Second State WebAssembly engine.
https://www.secondstate.io/articles/getting-started-with-rust-function/
161 stars 410 forks source link

Docker: rustwasmc build fails on rustc v.1.5.0 #21

Open zavalyshyn opened 2 years ago

zavalyshyn commented 2 years ago

Hi, I'm following your tutorial using your provided Docker container.

When I use wasmedge/appdev_x86_64:0.8.2 Docker image the rustwasmc build command fails when trying to compile a bumpalo-3.9.1 package:

root@740af9646213:/app# rustwasmc build
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
   Compiling bumpalo v3.9.1
error[E0658]: arbitrary expressions in key-value attributes are unstable
 --> /root/.cargo/registry/src/github.com-1ecc6299db9ec823/bumpalo-3.9.1/src/lib.rs:1:10
  |
1 | #![doc = include_str!("../README.md")]
  |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: see issue #78835 <https://github.com/rust-lang/rust/issues/78835> for more information

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.
error: could not compile `bumpalo`

To learn more, run the command again with --verbose.
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
  full command: "cargo" "build" "--all-targets" "--release" "--target" "wasm32-wasi"

I suspect the build fails because of outdated rustc version used by wasmedge. It's 1.5.0 version in that Docker image.

When I try a more recent Docker image (wasmedge/appdev_x86_64:0.9.0) and run the same command I get the following:

root@c2ace0eecbc4:/app# rustwasmc build
Error: At this time, we can only support Rust compiler version 1.50 and below in order to support WASI features in WasmEdge. Please use this command to set Rust version:
$ rustup override set 1.50.0
If you do not need WASI features, you can use the —no-wasi flag to override this behavior. See more here: https://github.com/WasmEdge/WasmEdge/issues/264
root@c2ace0eecbc4:/app# rustc --version
rustc 1.57.0 (f1edd0429 2021-11-29)

So what is the right version to use? And what can I do to build your example code? Thanks

surfer1225 commented 2 years ago

I am facing the exact issue here, did you manage to make it work?

zavalyshyn commented 2 years ago

Since reporting this issue I installed wasmedge in my system directly (instead of using a Docker container). It makes things easier for me and I don't run into compatibility issues anymore.

dotgreg commented 1 year ago

I am facing the same problem, docker or base linux (ubuntu 21). Any updates on that point?

Error: Error during execution of `cargo metadata`:     Updating crates.io index
 Downloading crates ...
  Downloaded wasm-bindgen-shared v0.2.61
  Downloaded unicode-ident v1.0.11
  Downloaded quote v1.0.33
  Downloaded proc-macro2 v1.0.66
error: failed to parse manifest at `/root/.cargo/registry/src/github.com-1ecc6299db9ec823/proc-macro2-1.0.66/Cargo.toml`

Caused by:
  failed to parse the `edition` key

Caused by:
  this version of Cargo is older than the `2021` edition, and only supports `2015` and `2018` editions.
hydai commented 1 year ago

rustwasmc is no longer updated. Instead, we moved forward to the quickjs solution for the nodejs extensions. Ref: https://github.com/second-state/wasmedge-quickjs

I will make this repo a public archive.