Closed mqsoh closed 5 years ago
We can actually completely remove the talk of installing the wasm32-unknown-unknown
target manually, since wasm-pack
will add it for you if needed!
That doesn't happen for me in a fresh environment.
$ docker run -it --rm --env USER rust:1.33.0-stretch bash -c '
cargo install cargo-generate;
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh;
cargo generate --git https://github.com/rustwasm/wasm-pack-template --name wasm-game-of-life;
cd wasm-game-of-life;
wasm-pack build;
'
...redacted a bunch of compiling...
Compiling cargo-generate v0.2.2
Finished release [optimized] target(s) in 3m 00s
Installing /usr/local/cargo/bin/cargo-generate
info: downloading wasm-pack
info: successfully installed wasm-pack to `/usr/local/cargo/bin/wasm-pack`
Creating project called `wasm-game-of-life`...
Done! New project created /wasm-game-of-life
[INFO]: Checking for the Wasm target...
Error: wasm32-unknown-unknown target not found!
$
Well, but I see here the wasm-pack docs say that it will automatically download the wasm32-unknown-unknown target. I wonder if wasm-pack thinks it's not in a Rust environment in Docker...
I did some digging and opened an issue in the wasm-pack repo.
@mqsoh @fitzgen it's still in the docs as needing the "wasm32-unknown-unknown target installed via rustup." https://rustwasm.github.io/docs/book/game-of-life/hello-world.html (See Build the Project section)
It's a slight distraction to a newbie like me who may be struggling to just to get their environment setup... because the docs do not say how to install the target.
And even rustup --help
does not reveal the "add" subcommand.
All that said, I found the add syntax in the initial issue post above. I haven't confirmed if wasm-pack makes this obsolete.
I'm happy to help edit the docs but I'd need some pointers on how to get started there.
My issue was that wasm-pack didn't install the wasm32-unknown-unknown target automatically like it was supposed to. It's because the wasm-pack code was checking for rustup in a way that was inconsistent with the way rustup is distributed in the official Rust Docker image. It works now. I just tried it with the latest:
$ docker run -it --rm --env USER rust:1.46 bash -c '
cargo install cargo-generate;
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh;
cargo generate --git https://github.com/rustwasm/wasm-pack-template --name wasm-game-of-life;
cd wasm-game-of-life;
wasm-pack build;
...REDACTED compiling output...
Finished release [optimized] target(s) in 14.20s
[INFO]: Installing wasm-bindgen...
[INFO]: Optimizing wasm binaries with `wasm-opt`...
[INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended
[INFO]: :-) Done in 17.71s
[INFO]: :-) Your wasm pkg is ready to publish at /wasm-game-of-life/pkg.
I don't know if the docs have been updated since last I read them, but the wording seems correct to me now. The confusing line is bulleted under "We use wasm-pack to orchestrate the following build steps:" implying that wasm-pack does this for you.
It should do that for you. If it doesn't, then your issue isn't related to mine.
What was the resolution to this issue? Why was it closed? The line telling us to "ensure that we have...the wasm32-unknown-unknown target installed via rustup" still offers no guidance on how to do so.
I submitted a ticket to the wasm-pack repo and they patched it so that it supports the rustup as installed in the Docker image.
My last message was too verbose. I was saying, and demonstrating, that It works now.
@mqsoh Cool, thanks. ~Would it make sense to remove the confusing line? #268~
I misunderstood this line:
We use wasm-pack to orchestrate the following build steps
I mistook the bulleted list for prerequisites. I see now that "use wasm-pack to orchestrate" here means "wasm-pack will do this for you, so this is just an FYI list, not something you really even need to think about."
@mqsoh Cool, thanks. ~Would it make sense to remove the confusing line? #268~
I misunderstood this line:
We use wasm-pack to orchestrate the following build steps
I mistook the bulleted list for prerequisites. I see now that "use wasm-pack to orchestrate" here means "wasm-pack will do this for you, so this is just an FYI list, not something you really even need to think about."
FWIW, going through the tutorial I also misunderstood this statement. Some rewording of these instructions may be beneficial to improve clarity.
We can actually completely remove the talk of installing the wasm32-unknown-unknown target manually, since wasm-pack will add it for you if needed!
Didn't work for me when I added it to Cargo.toml
in https://github.com/Sword-Smith/omnizk. Running rustup target add wasm32-unknown-unknown
worked though.
Where in the docs did you come across this?
4.2 Hello, World!
Describe what about it does not make sense
It says to
Why does it not make sense?
It's not part of the setup instructions in section 4.1. I found a page that shows how to install it but it's not up to date. I installed it without the "nightly" stuff and it seems to work.
How could we improve it?
I think you just need to add that line to section 4.1. I thought about making a pull request, but each section has a description of the tool and I'm not entirely sure what to say about it.