wasm-pack: Error for missing wasm32-unknown-unknown on non-rustup environments can be improved

🐛 Bug description

As a newbie I am following the tutorial at https://rustwasm.github.io/book/game-of-life/hello-world.html and get errors

🤔 Expected Behavior

When building the project with wasm-pack build I expect no errors.

👟 Steps to reproduce

$ cargo generate --git https://github.com/rustwasm/wasm-pack-template

then type wasm-game-of-life

$ cd wasm-game-of-life
$ wasm-pack build
[INFO]: 🎯  Checking for the Wasm target...
Error: wasm32-unknown-unknown target not found!

🌍 Your environment

Include the relevant details of your environment. wasm-pack version: 0.7.0 rustc version: 1.31.0 MacOS Sierra

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 2
  • Comments: 20 (11 by maintainers)

Most upvoted comments

I reinstalled rust via brew and confirm that building a project fails until I uninstall brew rust.

FWIW I think this is an expected error and one that we probably want to just improve the error message in the long-term perhaps. @gotcha sounds like you had a mixup of brew-install-rust as well as rustup-installed-rust at the beginning, and I believe what happened here was that you brew-installed-rust was first in PATH which meant that the wasm target wasn’t already installed and wasm-pack deduced it couldn’t install it, giving an error message.

What we probably want to do in this case is to improve the error message to indicate:

  • Primarily, where rustc was located
  • Wording indicating that it looks like it’s not rustup
  • Wording to indicate that we couldn’t find wasm32-unknown-unknown in the sysroot (and the absolute path we didn’t find)
  • Finally, wording to indicate that wasm32-unknown-unknown needs to be installed manually on non-rustup setups, and this could eventually point to a documentation link in wasm-pack’s docs

Sure, I’ll make a new thread.

@gotcha yeah there is a small lag between when i make a release and when the installer works because of latency! glad to hear you were able to build the project! i’m going to leave this open because i want to make sure that we can work when someone has both a brew installed and rustup installed rust(s)! thanks for your diligence here and glad you got it to work!

@ashleygwilliams BTW, the script at https://rustwasm.github.io/wasm-pack/installer/ fails because it references a 0.6.1 release that does not exist.

I’ve gone ahead and retitled this issue as well to describe what I think the issue is