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-wasiI 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 forstd
|
= note: thewasm32-wasi
target may not be installed
= help: consider downloading the target withrustup 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_itemFor more information about this error, try
rustc --explain E0463
.
error: could not compilehello-rust
due to 3 previous errorsComment: not a good optic when the first example wont compile
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.
fgmccabe commented on issue #6035:
Well, I actually also tried rustup; with identical results
saulecabrera commented on issue #6035:
As a sanity check: did you remove the rust version installed by homebrew? (
brew rm -f rust
)
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 getwasm32-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 didbrew install rust
andbrew 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: yourrustup target add wasm32-wasi
added thewasm32-wasi
SDK for the Rustup-installed toolchain, but then when you docargo build
you invoke your Homebrew-installed toolchain.Could you:
- Report to us what you see for
which cargo
andwhich rustc
;- If that is not
/Users/fgm/.cargo/bin/{cargo,rustc}
, uninstall the brew-installed packages;- If that also removes rustup itself, either do the
curl | sh
install method (curl https://sh.rustup.rs | bash
) or look to see if Rustup is in Homebrew's packages;- Restart your shell to make sure you get env variables fresh from any changes made by the above.
fgmccabe commented on issue #6035:
I removed the brew version of rust as suggested.
It now works, thanks
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-wasiI 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 forstd
|
= note: thewasm32-wasi
target may not be installed
= help: consider downloading the target withrustup 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_itemFor more information about this error, try
rustc --explain E0463
.
error: could not compilehello-rust
due to 3 previous errorsComment: not a good optic when the first example wont compile
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
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: Dec 23 2024 at 12:05 UTC