Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rustup target add wasm32-wasi into the wasm-learning/cli/hello/ example #38

Closed
TieWay59 opened this issue May 8, 2022 · 2 comments · Fixed by #39
Closed

Add rustup target add wasm32-wasi into the wasm-learning/cli/hello/ example #38

TieWay59 opened this issue May 8, 2022 · 2 comments · Fixed by #39

Comments

@TieWay59
Copy link
Contributor

TieWay59 commented May 8, 2022

The hello file does not mention rustup target add wasm32-wasi before building as a beginner example. I believe it is better for newcomers.

$ rustup target add wasm32-wasi
$ cargo build --target wasm32-wasi

## Build the WASM bytecode
```
$ cargo build --target wasm32-wasi
```

The error log will be very confusing if someone forgets to add the target before building for the first time.

root@TW59:~/wasm-learning/cli/hello# cargo build --target wasm32-wasi
   Compiling hello v0.1.0 (/root/wasm-learning/cli/hello)
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[E0463]: can't find crate for `std`
 --> src/main.rs:1:5
  |
1 | use std::env;
  |     ^^^ can't find crate
  |
  = 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:6:5
  |
6 |     println!("{}", argument);
  |     ^^^^^^^

error: cannot find macro `println` in this scope
 --> src/main.rs:4:3
  |
4 |   println!("hello");
  |   ^^^^^^^

error[E0433]: failed to resolve: use of undeclared crate or module `env`
 --> src/main.rs:5:19
  |
5 |   for argument in env::args().skip(1) {
  |                   ^^^ use of undeclared crate or module `env`

error: requires `sized` lang_item

Some errors have detailed explanations: E0433, E0463.
For more information about an error, try `rustc --explain E0433`.
error: could not compile `hello` due to 6 previous errors

Reference:

WASI-tutorial.md this file gives an shell example with add target.

@juntao
Copy link
Member

juntao commented May 9, 2022

Can you send a PR to fix this? :) Thanks!

@TieWay59
Copy link
Contributor Author

Can you send a PR to fix this? :) Thanks!

NP. I opened this issue to track the discussion, I'll close it once it's merged.

TieWay59 added a commit to TieWay59/wasm-learning that referenced this issue May 10, 2022
Close second-state#38

Signed-off-by: TieWay59 <tieway59@foxmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants