Stream: git-wasmtime

Topic: wasmtime / issue #6035 hello world from the intro does no...


view this post on Zulip Wasmtime GitHub notifications bot (Mar 16 2023 at 22:21):

fgmccabe opened issue #6035:

Following the very first section on creating a hello world example.

I used
brew install rust
brew install cargo
rustup target add wasm32-wasi
cargo new hello-world
cargo build --target wasm32-wasi

I get this:

cargo build --target wasm32-wasi

Compiling hello-rust v0.1.0 (/Users/fgm/Projects/helloworld/hello-rust)
error[E0463]: can't find crate for std
|
= note: the wasm32-wasi target may not be installed
= help: consider downloading the target with rustup target add wasm32-wasi

error: cannot find macro println in this scope
--> src/main.rs:2:5
|
2 | println!("Hello, world!");
| ^^^^^^^

error: requires sized lang_item

For more information about this error, try rustc --explain E0463.
error: could not compile hello-rust due to 3 previous errors

Comment: not a good optic when the first example wont compile

view this post on Zulip Wasmtime GitHub notifications bot (Mar 16 2023 at 22:26):

bjorn3 commented on issue #6035:

The instructions assume that you installed rustc using rustup rather than an unofficial method like homebrew in your case. I'm not familiar with the homebrew version of rustc, so I don't know how to install the rust standard library for wasm32-wasi using homebrew. If they even compile it for wasm32-wasi at all.

view this post on Zulip Wasmtime GitHub notifications bot (Mar 16 2023 at 22:30):

fgmccabe commented on issue #6035:

Well, I actually also tried rustup; with identical results

view this post on Zulip Wasmtime GitHub notifications bot (Mar 16 2023 at 22:32):

saulecabrera commented on issue #6035:

As a sanity check: did you remove the rust version installed by homebrew? (brew rm -f rust)

view this post on Zulip Wasmtime GitHub notifications bot (Mar 16 2023 at 22:32):

cfallin commented on issue #6035:

@fgmccabe to elaborate a little bit (strictly speaking this is a Rust issue, not a Wasmtime issue, but since we're all here...): the Rust toolchain is most commonly installed via the "rustup" tool, which knows how to download new versions of the toolchain and target SDKs. (That's the rustup target add... bit to get wasm32-wasi.) However, many package collections and distributions also include custom-packaged snapshots of the individual tools (Rust compiler, Cargo). That's what you got when you did brew install rust and brew install cargo, and same would be true with e.g. apt install rust on a Debian-ish Linux.

I suspect what's happening here is a $PATH conflict: your rustup target add wasm32-wasi added the wasm32-wasi SDK for the Rustup-installed toolchain, but then when you do cargo build you invoke your Homebrew-installed toolchain.

Could you:

view this post on Zulip Wasmtime GitHub notifications bot (Mar 16 2023 at 23:07):

fgmccabe commented on issue #6035:

I removed the brew version of rust as suggested.
It now works, thanks

view this post on Zulip Wasmtime GitHub notifications bot (Mar 16 2023 at 23:07):

fgmccabe closed issue #6035:

Following the very first section on creating a hello world example.

I used
brew install rust
brew install cargo
rustup target add wasm32-wasi
cargo new hello-world
cargo build --target wasm32-wasi

I get this:

cargo build --target wasm32-wasi

Compiling hello-rust v0.1.0 (/Users/fgm/Projects/helloworld/hello-rust)
error[E0463]: can't find crate for std
|
= note: the wasm32-wasi target may not be installed
= help: consider downloading the target with rustup target add wasm32-wasi

error: cannot find macro println in this scope
--> src/main.rs:2:5
|
2 | println!("Hello, world!");
| ^^^^^^^

error: requires sized lang_item

For more information about this error, try rustc --explain E0463.
error: could not compile hello-rust due to 3 previous errors

Comment: not a good optic when the first example wont compile

view this post on Zulip Wasmtime GitHub notifications bot (Mar 16 2023 at 23:07):

fgmccabe commented on issue #6035:

Actually, a follow up: it would be good to mention the potential pitfalls in the intro. Installing packages using brew is pretty normal in mac-land

view this post on Zulip Wasmtime GitHub notifications bot (Mar 16 2023 at 23:16):

cfallin commented on issue #6035:

Actually, a follow up: it would be good to mention the potential pitfalls in the intro. Installing packages using brew is pretty normal in mac-land

Good idea; added in #6036.


Last updated: Nov 22 2024 at 16:03 UTC