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

Error for missing wasm32-unknown-unknown on non-rustup environments can be improved #579

Closed
gotcha opened this issue Mar 16, 2019 · 20 comments · Fixed by #602
Closed

Error for missing wasm32-unknown-unknown on non-rustup environments can be improved #579

gotcha opened this issue Mar 16, 2019 · 20 comments · Fixed by #602
Assignees
Labels
bug Something isn't working PR attached there's a PR open for this issue user report
Milestone

Comments

@gotcha
Copy link

gotcha commented Mar 16, 2019

🐛 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

@ashleygwilliams
Copy link
Member

looks like this is a bug in the new, not quite yet released version of wasm-pack! thanks for filing i will get right on it!

@ashleygwilliams ashleygwilliams added bug Something isn't working user report labels Mar 16, 2019
@ashleygwilliams ashleygwilliams added this to the 0.7.0 milestone Mar 16, 2019
@ashleygwilliams
Copy link
Member

i just ran this on my machine with the current tagged 0.7.0 (which due to some clumsiness on my part may not be the version 0.7.0 that you have @gotcha ) and got this, which is the expected behavior:

ag-dubss-MacBook-Pro:wasm-pack ag_dubs$ rustup target remove wasm32-unknown-unknown
info: removing component 'rust-std' for 'wasm32-unknown-unknown'
ag-dubss-MacBook-Pro:wasm-pack ag_dubs$ cargo run -- build ../hello-wasm/
    Finished dev [unoptimized + debuginfo] target(s) in 0.59s
     Running `target/debug/wasm-pack build ../hello-wasm/`
[INFO]: 🎯  Checking for the Wasm target...
info: downloading component 'rust-std' for 'wasm32-unknown-unknown'
info: installing component 'rust-std' for 'wasm32-unknown-unknown'
[INFO]: 🌀  Compiling to Wasm...
    Finished release [optimized] target(s) in 0.20s
[INFO]: ⬇️  Installing wasm-bindgen...
[INFO]: Optional fields missing from Cargo.toml: 'description', 'repository', and 'license'. These are not necessary, but recommended
[INFO]: ✨   Done in 2.24s
[INFO]: 📦   Your wasm pkg is ready to publish at ../hello-wasm/pkg.

i think you are using a faulty release that i made last night/this morning. if you can give me a few minutes there should be a new one. if you uninstall and reinstall you should be all set. i'll come back here and comment when the new release is posted.

@gotcha
Copy link
Author

gotcha commented Mar 16, 2019

@ashleygwilliams In the meanwhile, I checked my setup and found a mix of rust installed via brew and rustup.
I removed everything and am in the process of installing a fresh rust with rustup.

@ashleygwilliams
Copy link
Member

ashleygwilliams commented Mar 16, 2019

@gotcha that's very helpful info! that being said, this release is supposed to support non-rustup setups, tho we may not have considered the multiple rusts scenario - we definitely don't want the error you got, even in the env you had, so we should try to reproduce and make sure it works.

do let me know if updating your env helps! that'll be useful. either way, thanks so much for filing!

@gotcha
Copy link
Author

gotcha commented Mar 16, 2019

@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.

@gotcha
Copy link
Author

gotcha commented Mar 16, 2019

@ashleygwilliams With a fresh rust setup (1.33.0) with rustup, I manage to build the project.

@gotcha
Copy link
Author

gotcha commented Mar 16, 2019

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

@ashleygwilliams This is fixed. I guess you will update https://rustwasm.github.io/ to mention 0.7.0.

@ashleygwilliams
Copy link
Member

@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 ashleygwilliams modified the milestones: 0.7.0, 0.8.0 Mar 16, 2019
@gotcha
Copy link
Author

gotcha commented Mar 16, 2019

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

@ashleygwilliams
Copy link
Member

@gotcha yup! i just had a conversation with @drager in the #wg-wasm channel on the rust discord. i will need to actually dive into the code to confirm, but my suspicion is this is what happens:

  1. wasm-pack checks for rustup
  2. wasm-pack finds rustup
  3. wasm-pack checks for rustup rust wasm32 target
  4. it installs it or it doesn't
  5. wasm-pack tries to build ur project but uses non-rustup rust (in this case brew)
  6. the brew rust was never checked for the target, and if it doesn't have it (in this case it didn't) it fails

so fundamentally we are not currently guaranteeing that the rust we check for the target is the rust we use to build the project. this is because we didn't account for folks who have 2 rust setups on their machine (an edge case likely, but one we should do our best to account for)!

to fix this, the user can manually install the wasm32 target, and it should work! but hopefully we can tighten up this process so we don't have to offer a manual remedy.

thanks for filing this issue- it's a really interesting problem!

@gotcha
Copy link
Author

gotcha commented Mar 16, 2019

Thanks for the very gentle followup !

@strangelittlemonkey
Copy link

Is it expected that wasm-pack only work on 32bit and 32bit compatible systems? I'm attempting to build on a system that has dropped 32bit support and is 64bit only and also does not have rustup support.

I tried building off commit badbe1c, as well as off the 0.6.0 tag and the 0.7.0 tag, all failed. This was as well with the hello world example.

In order: 0.6.0, 0.7.0, master

zach@dev03 ~/wasm-pack-template> wasm-pack build
[1/10] Checking rustc version...
[2/10] Checking crate configuration...
| [3/10] Adding WASM target...
Error: Adding the wasm32-unknown-unknown target with rustup
Caused by: No such file or directory (os error 2)
zach@dev03 ~/wasm-pack-template> ../wasm-pack/target/release/wasm-pack build
[INFO]: Checking for the Wasm target...
Error: wasm32-unknown-unknown target not found!
zach@dev03 ~/wasm-pack-template> ../wasm-pack/target/release/wasm-pack build
[INFO]: Checking for the Wasm target...
Error: wasm32-unknown-unknown target not found!

@ashleygwilliams
Copy link
Member

@strangelittlemonkey nope- or at least i do not believe so. this seems like a different situation than this thread tho- would you mind filing a new issue?

@ashleygwilliams
Copy link
Member

(i might be wrong... but just in case! don't want to lose track of it!)

@strangelittlemonkey
Copy link

Sure, I'll make a new thread.

@strangelittlemonkey
Copy link

For posterity sake, I'll update this with a discovery from another issue here, which is that wasm is presently 32bit and requires a 32bit system, whether that be the host or the compatibility layer, one or both must be 32bit for wasm at this time.

@Pauan
Copy link
Contributor

Pauan commented Mar 17, 2019

@strangelittlemonkey Yes, the wasm runtime is 32-bits, but the wasm runtime is in the browser.

And 64-bit browsers run 32-bit wasm runtimes natively, since that is mandated by the W3C spec. I believe that is true even on 64-bit only systems.

The issue you are getting is during compile time, long before running in the browser. So I don't think it's related to the 32-bitness of wasm.

@alexcrichton
Copy link
Contributor

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

@alexcrichton alexcrichton changed the title Following tutorial leads to Error: wasm32-unknown-unknown target not found! Error for missing wasm32-unknown-unknown on non-rustup environments can be improved Mar 18, 2019
@alexcrichton
Copy link
Contributor

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

@drager
Copy link
Member

drager commented Mar 23, 2019

I'm currently working on a PR to improve the error message and docs for this as suggested by @alexcrichton.

@ashleygwilliams ashleygwilliams added the PR attached there's a PR open for this issue label Mar 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PR attached there's a PR open for this issue user report
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants