wasm-pack icon indicating copy to clipboard operation
wasm-pack copied to clipboard

local wasm-bindgen is not used at all, fails with error "Error: Not able to find or install a local wasm-bindgen."

Open woss opened this issue 2 years ago • 1 comments

🐛 Bug description

When specifying the --no-install the wasm-pack tries to install the wasm-bindgen regardless even though it is found and refuses to use it. This shouldn't happen since the --no-install must obey the local binary if found, regardless of the version, which it doesn't because it always is looking for new one.

Here are some notes:

  • https://github.com/rustwasm/wasm-pack/blob/master/src/install/mod.rs#L74 it all starts
  • via this https://github.com/rustwasm/wasm-pack/blob/master/src/install/mod.rs#L139
  • then the cache.download( ends up calling the version that is not supported (0.0.2 and repo URL doesn't work ) and that version will respond with Ok(None) which is somewhat OK but that should never be called since i as a user don't want to use new version
image

Here is to command i use

[tasks.esm-dev]
condition = { profiles = ["development"] }
category = "wasm"
args = [
  "--log-level",
  "warn",
  "--verbose",
  "build",
  "--target",
  "bundler",
  "--out-dir",
  "pkg/dev/esm",
  "--dev",
  "--mode",
  "no-install",
]
command = "wasm-pack"
description = "Build the WASM-PACK for the bundler in dev mode"
watch = true

🤔 Expected Behavior

What should have happened?

To use the local version and not try to either download it or install it via cargo.

👟 Steps to reproduce

have the older version of wasm-bindgen then run the wasm-pack build with --no-install

🌍 Your environment

Include the relevant details of your environment. wasm-pack version: wasm-pack 0.10.2 rustc version: rustc 1.59.0 (9d1b2106e 2022-02-23)

woss avatar May 18 '22 08:05 woss

I think the error message is hiding important information. In my case the version of wasm-bindgen I had installed wasn't the version expected. For the benefit of anyone coming here seeing this message after using create-yew-app, I'd suggest setting RUST_LOG=debug and looking for a line like the following:

INFO 2023-02-21T20:37:08Z: wasm_pack::install: 
Checking installed `wasm-bindgen` version == expected version: 0.2.83 == 0.2.84

After a subsequent cargo install -f wasm-bindgen-cli the problem was resolved (for now)

Sample run
  % RUST_LOG="debug" npm start
    
    > [email protected] start
    > cross-env WASM_PACK_PROFILE=dev parcel static/index.html -p 8000 --open
    
    Server running at http://localhost:8000 
    🚨xxxxxx/my-app/Cargo.toml: Command failed: wasm-pack build -m no-install --dev
     INFO 2023-02-21T20:37:06Z: wasm_pack::command: Running build command...
     INFO 2023-02-21T20:37:07Z: wasm_pack::command::build: Checking rustc version...
     INFO 2023-02-21T20:37:07Z: wasm_pack::command::build: rustc version is 65.
     INFO 2023-02-21T20:37:07Z: wasm_pack::command::build: Checking crate configuration...
     INFO 2023-02-21T20:37:07Z: wasm_pack::command::build: Crate is correctly configured.
     INFO 2023-02-21T20:37:07Z: wasm_pack::command::build: Checking for wasm-target...
    [INFO]: Checking for the Wasm target...
     INFO 2023-02-21T20:37:07Z: wasm_pack::build::wasm_target: Looking for wasm32-unknown-unknown in "~/.rustup/toolchains/1.65.0-x86_64-apple-darwin/lib/rustlib"
     INFO 2023-02-21T20:37:07Z: wasm_pack::build::wasm_target: Found wasm32-unknown-unknown in "~/.rustup/toolchains/1.65.0-x86_64-apple-darwin/lib/rustlib"
     INFO 2023-02-21T20:37:07Z: wasm_pack::command::build: Checking for wasm-target was successful.
     INFO 2023-02-21T20:37:07Z: wasm_pack::command::build: Building wasm...
    [INFO]: Compiling to Wasm...
     INFO 2023-02-21T20:37:07Z: wasm_pack::child: Running "cargo" "build" "--lib" "--target" "wasm32-unknown-unknown"
        Finished dev [unoptimized + debuginfo] target(s) in 0.24s
     INFO 2023-02-21T20:37:08Z: wasm_pack::command::build: wasm built at "xxxxxx/my-app/target/wasm32-unknown-unknown/release".
     INFO 2023-02-21T20:37:08Z: wasm_pack::command::build: Creating a pkg directory...
     INFO 2023-02-21T20:37:08Z: wasm_pack::command::build: Created a pkg directory at "xxxxxx/my-app".
     INFO 2023-02-21T20:37:08Z: wasm_pack::command::build: Copying readme from crate...
     INFO 2023-02-21T20:37:08Z: wasm_pack::command::build: Copied readme from crate to "xxxxxx/my-app/pkg".
     INFO 2023-02-21T20:37:08Z: wasm_pack::command::build: Copying license from crate...
     INFO 2023-02-21T20:37:08Z: wasm_pack::command::build: Copied license from crate to "xxxxxx/my-app/pkg".
     INFO 2023-02-21T20:37:08Z: wasm_pack::command::build: Identifying wasm-bindgen dependency...
     INFO 2023-02-21T20:37:08Z: wasm_pack::command::build: Installing wasm-bindgen-cli...
    DEBUG 2023-02-21T20:37:08Z: wasm_pack::install: found global wasm-bindgen binary at: ~/.cargo/bin/wasm-bindgen
     INFO 2023-02-21T20:37:08Z: wasm_pack::child: Running "~/.cargo/bin/wasm-bindgen" "--version"
>>>  INFO 2023-02-21T20:37:08Z: wasm_pack::install: Checking installed `wasm-bindgen` version == expected version: 0.2.83 == 0.2.84
    [INFO]: Installing wasm-bindgen...
     WARN 2023-02-21T20:37:08Z: wasm_pack::install: could not download pre-built `wasm-bindgen`: wasm-bindgen v0.2.84 is not installed!. Falling back to `cargo install`.
    DEBUG 2023-02-21T20:37:08Z: wasm_pack::install: Attempting to use a `cargo install`ed version of `wasm-bindgen=0.2.84`
     INFO 2023-02-21T20:37:08Z: wasm_pack::command::build: Installing wasm-bindgen-cli was successful.
     INFO 2023-02-21T20:37:08Z: wasm_pack::command::build: Building the wasm bindings...
    Error: Not able to find or install a local wasm-bindgen.
    
  % wasm-bindgen --version
    wasm-bindgen 0.2.83

  % cargo install -f wasm-bindgen-cli
        Updating crates.io index
      Installing wasm-bindgen-cli v0.2.84
      ...
        Finished release [optimized] target(s) in 1m 20s
       Replacing ~/.cargo/bin/wasm-bindgen
       Replacing ~/.cargo/bin/wasm-bindgen-test-runner
       Replacing ~/.cargo/bin/wasm2es6js
        Replaced package `wasm-bindgen-cli v0.2.83` with `wasm-bindgen-cli v0.2.84` (executables `wasm-bindgen`, `wasm-bindgen-test-runner`, `wasm2es6js`)

  % npm start
    
    > [email protected] start
    > cross-env WASM_PACK_PROFILE=dev parcel static/index.html -p 8000 --open
    
    Server running at http://localhost:8000 
    ⠋ Building...
    ✨  Built in 5.57s.

    ... works as expected

jq170727 avatar Feb 21 '23 21:02 jq170727