wasm-tool / wasm-pack-plugin

webpack plugin for Rust
MIT License
315 stars 70 forks source link

Do not attempt to install wasm-pack globally via npm #138

Closed Selicre closed 1 year ago

Selicre commented 2 years ago

When the script attempts to install wasm-pack if it doesn't exist, it does so with the -g flag, which by default tries to install in /usr/lib, which the running user likely has no permissions for. This is then reported as a "Rust compilation error" with no further information, leading to a wild goose chase on what the actual problem is.

Steps to reproduce:

  1. Attempt to run any example without installing wasm-pack first, with npm available.

Proposed fixes:

  1. Remove the -g flag.
  2. Collect stdout/stderr and give it to the user in case the command fails.
  3. Use a more descriptive error message for each subprocess call.
JosephLenton commented 2 years ago

Hey, I had this very problem myself yesterday. It took me an hour to work out what the underlying issue is.

There might be a debate as to if this plugin should try to install Wasm-Pack globally using NPM, or if it should not. Until that debate is made, I feel quite strongly this should in the meantime be outputting error information. Just so that it's easier to debug NPM and Yarn errors if they happen.