trunk icon indicating copy to clipboard operation
trunk copied to clipboard

M1 not working even when manually installing wasm-bindgen-cli

Open monomadic opened this issue 2 years ago • 10 comments

I know there are several issues about this, but most suggest installing wasm-bindgen-cli manually. Generally the log output when you do that is supposed to say:

Nov 16 20:58:47.971  INFO using system installed binary app="wasm-bindgen" version="0.2.78"

But nothing I do can force my system to use this. I've installed (cargo install wasm-bindgen-cli) and it is available in my path, and yet every time trunk outputs something like:

2022-06-24T10:44:12.707970Z  INFO calling wasm-bindgen for yew-example

Is there some way trunk can be forced to use the system version of wasm-bindgen? The config file only permits specifying a version, not a path.

UPDATE: I didn't have rosetta installed (I don't usually use it). MacOS doesn't actually inform you of this, it just fails. You can install rosetta by right clicking an app like Terminal.app, check 'open using rosetta', if it's not installed it will prompt you. From there go back to your trunk project and cargo clean and trunk serve.

monomadic avatar Jun 24 '22 10:06 monomadic

sounds like old question https://github.com/thedodd/trunk/pull/380

tiye avatar Jun 24 '22 12:06 tiye

anything we can do if maintainers do not respond?

tiye avatar Jun 24 '22 12:06 tiye

Having the same issue

trchristensen avatar Jun 25 '22 10:06 trchristensen

Read the update I posted above, see if that helps.

monomadic avatar Jun 28 '22 16:06 monomadic

I believe the issue is with sass, which has a similar issue to wasm-bindgen. Installing sass globally seems to work for me as a workaround for now:

npm install -g sass

texodus avatar Jun 28 '22 21:06 texodus

Hey folks, we've merged one of the PRs related to better M1 support. Keep us posted on problems and resolutions you might find. Thank you!

thedodd avatar Jun 30 '22 04:06 thedodd

I had this problem. Trunk would see that I did not already have the tools needed installed, and went off and downloaded them for me. Unfortunately, it downloaded intel binaries. The solution that worked for me was just to install the tools myself so that when trunk checked that I had tools installed, I did, and no attempt was made to download them.

tinkyholloway avatar Jul 01 '22 13:07 tinkyholloway

Mind letting me know if v0.16.0 helps with this at all? In the case of wasm-bindgen, it will fail because wasm-bindgen doesn't yet have M1 artifacts, so at least it will bail on you and tell you what the problem is instead of installing an incompatible bin.

thedodd avatar Jul 02 '22 03:07 thedodd

Cleared the caches and application files:

% rm -Rf ~/Library/Application\ Support/dev.trunkrs.trunk
% rm -Rf ~/Library/Caches/dev.trunkrs.trunk

Made sure that I did not have any system installed versions of the tools about:

% which wasm-bindgen
wasm-bindgen not found
% which wasm-opt
wasm-opt not found
% which sass
sass not found

Checked my software:

% trunk --version
trunk 0.16.0
% sw_vers
ProductName:	macOS
ProductVersion:	12.4
BuildVersion:	21F79
% uname -a
Darwin Chestnut-Tree-Cafe.local 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T8101 arm64

Ran a release build and confirmed that the tools were being downloaded:

~/Projects/trunk/examples/vanilla git:(master*)
% trunk -v build --release
2022-07-03T06:08:16.611102Z  INFO 📦 starting build
2022-07-03T06:08:16.612218Z  INFO spawning asset pipelines
2022-07-03T06:08:16.747178Z  INFO building vanilla-example
2022-07-03T06:08:16.747161Z  INFO copying & hashing css path="src/app.css"
2022-07-03T06:08:16.747189Z DEBUG cargo args args=["build", "--target=wasm32-unknown-unknown", "--manifest-path", "/Users/tinky/Projects/trunk/examples/vanilla/Cargo.toml", "--release", "--bin", "vanilla-example"]
2022-07-03T06:08:16.747229Z DEBUG system version not found for sass: cannot find binary path
2022-07-03T06:08:16.747613Z  INFO downloading sass version="1.50.0"
2022-07-03T06:08:16.747711Z  INFO finished copying & hashing css path="src/app.css"
   Compiling proc-macro2 v1.0.28
   Compiling unicode-xid v0.2.2
   Compiling syn v1.0.74
   Compiling wasm-bindgen-shared v0.2.74
   Compiling log v0.4.14
   Compiling cfg-if v1.0.0
   Compiling bumpalo v3.7.0
   Compiling lazy_static v1.4.0
   Compiling wasm-bindgen v0.2.74
   Compiling wee_alloc v0.4.5
   Compiling cfg-if v0.1.10
   Compiling memory_units v0.4.0
2022-07-03T06:08:18.452084Z  INFO installing sass log(build.rs), wasm-bindgen(build.rs), proc-macro2(build.rs), syn(build.rs), wee_alloc(build.rs), wasm-bindgen-shared...
2022-07-03T06:08:19.257554Z  INFO compiling sass/scss path="src/index.scss"
2022-07-03T06:08:19.257568Z DEBUG sass args args=["--no-source-map", "-s", "compressed", "/Users/tinky/Projects/trunk/examples/vanilla/src/index.scss", "/Users/tinky/Projects/trunk/examples/vanilla/dist/.stage/index.css"]
2022-07-03T06:08:19.867907Z  INFO finished compiling sass/scss path="src/index.scss"uild), wee_alloc(build), wasm-bindgen-shared(build), log(build), syn(build)
   Compiling quote v1.0.9
   Compiling wasm-bindgen-backend v0.2.74
   Compiling wasm-bindgen-macro-support v0.2.74
   Compiling wasm-bindgen-macro v0.2.74
   Compiling js-sys v0.3.51
   Compiling console_error_panic_hook v0.1.6
   Compiling web-sys v0.3.51
   Compiling vanilla-example v0.1.0 (/Users/tinky/Projects/trunk/examples/vanilla)
    Finished release [optimized] target(s) in 11.50s
2022-07-03T06:08:28.293728Z  INFO fetching cargo artifacts
2022-07-03T06:08:28.365665Z  INFO processing WASM for vanilla-example
2022-07-03T06:08:28.367318Z DEBUG system version not found for wasm-bindgen: cannot find binary path
2022-07-03T06:08:28.367372Z  INFO downloading wasm-bindgen version="0.2.74"
2022-07-03T06:08:29.160168Z  INFO installing wasm-bindgen
2022-07-03T06:08:29.210502Z  INFO calling wasm-bindgen for vanilla-example
2022-07-03T06:08:29.210515Z DEBUG wasm-bindgen args args=["--target=web", "--out-dir=/Users/tinky/Projects/trunk/examples/vanilla/target/wasm-bindgen/release", "--out-name=vanilla-example-c02217194a3688fd", "/Users/tinky/Projects/trunk/examples/vanilla/target/wasm32-unknown-unknown/release/vanilla-example.wasm", "--no-typescript"]
2022-07-03T06:08:29.580403Z  INFO copying generated wasm-bindgen artifacts
2022-07-03T06:08:29.581250Z DEBUG system version not found for wasm-opt: cannot find binary path
2022-07-03T06:08:29.581303Z  INFO downloading wasm-opt version="version_105"
2022-07-03T06:08:34.418492Z  INFO installing wasm-opt
2022-07-03T06:08:34.531767Z  INFO calling wasm-opt
2022-07-03T06:08:34.531779Z DEBUG wasm-opt args args=["--output=/Users/tinky/Projects/trunk/examples/vanilla/target/wasm-opt/release/vanilla-example-c02217194a3688fd_bg.wasm", "-Oz", "/Users/tinky/Projects/trunk/examples/vanilla/dist/.stage/vanilla-example-c02217194a3688fd_bg.wasm"]
2022-07-03T06:08:35.224425Z  INFO copying generated wasm-opt artifacts
2022-07-03T06:08:35.225220Z  INFO applying new distribution
2022-07-03T06:08:35.226117Z  INFO ✅ success

Everything seems to work. Checking out the downloaded tools:

~/Library/Caches/dev.trunkrs.trunk
% file wasm-opt-version_105/bin/wasm-opt
wasm-opt-version_105/bin/wasm-opt: Mach-O 64-bit executable arm64

~/Library/Caches/dev.trunkrs.trunk
% file wasm-bindgen-0.2.74/wasm-bindgen
wasm-bindgen-0.2.74/wasm-bindgen: Mach-O 64-bit executable x86_64

~/Library/Caches/dev.trunkrs.trunk
% file sass-1.50.0/sass
sass-1.50.0/sass: POSIX shell script text executable, ASCII text

The mac is doing its fu with the x86_64 wasm-bindgen binary:

% ./wasm-bindgen-0.2.74/wasm-bindgen -V
wasm-bindgen 0.2.74 (27c7a4d06)

Now, I install the tools separately:

% cargo install wasm-bindgen-cli
% brew install binaryen
% brew install sass

so

% which sass
/opt/homebrew/bin/sass
~
% which wasm-opt
/opt/homebrew/bin/wasm-opt
~
% which wasm-bindgen
/Users/tinky/.cargo/bin/wasm-bindgen

and rerun the build:

% trunk clean
~/Projects/trunk/examples/vanilla git:(master*)
% trunk -v build --release
2022-07-03T06:53:39.248196Z  INFO 📦 starting build
2022-07-03T06:53:39.249415Z  INFO spawning asset pipelines
2022-07-03T06:53:39.405994Z  INFO building vanilla-example
2022-07-03T06:53:39.405961Z  INFO copying & hashing css path="src/app.css"
2022-07-03T06:53:39.406009Z DEBUG cargo args args=["build", "--target=wasm32-unknown-unknown", "--manifest-path", "/Users/tinky/Projects/trunk/examples/vanilla/Cargo.toml", "--release", "--bin", "vanilla-example"]
2022-07-03T06:53:39.406210Z  INFO finished copying & hashing css path="src/app.css"
    Finished release [optimized] target(s) in 0.03s
2022-07-03T06:53:39.484069Z  INFO fetching cargo artifacts
2022-07-03T06:53:39.552592Z  INFO processing WASM for vanilla-example
2022-07-03T06:53:39.917170Z  INFO using system installed binary app=sass version=1.53.0
2022-07-03T06:53:39.917205Z  INFO compiling sass/scss path="src/index.scss"
2022-07-03T06:53:39.917210Z DEBUG sass args args=["--no-source-map", "-s", "compressed", "/Users/tinky/Projects/trunk/examples/vanilla/src/index.scss", "/Users/tinky/Projects/trunk/examples/vanilla/dist/.stage/index.css"]
2022-07-03T06:53:39.938314Z  INFO finished compiling sass/scss path="src/index.scss"
2022-07-03T06:53:40.179376Z  INFO calling wasm-bindgen for vanilla-example
2022-07-03T06:53:40.179401Z DEBUG wasm-bindgen args args=["--target=web", "--out-dir=/Users/tinky/Projects/trunk/examples/vanilla/target/wasm-bindgen/release", "--out-name=vanilla-example-c02217194a3688fd", "/Users/tinky/Projects/trunk/examples/vanilla/target/wasm32-unknown-unknown/release/vanilla-example.wasm", "--no-typescript"]
2022-07-03T06:53:40.243233Z  INFO copying generated wasm-bindgen artifacts
2022-07-03T06:53:40.933402Z  INFO using system installed binary app=wasm-opt version=version_109
2022-07-03T06:53:40.933459Z  INFO calling wasm-opt
2022-07-03T06:53:40.933463Z DEBUG wasm-opt args args=["--output=/Users/tinky/Projects/trunk/examples/vanilla/target/wasm-opt/release/vanilla-example-c02217194a3688fd_bg.wasm", "-Oz", "/Users/tinky/Projects/trunk/examples/vanilla/dist/.stage/vanilla-example-c02217194a3688fd_bg.wasm"]
2022-07-03T06:53:41.010143Z  INFO copying generated wasm-opt artifacts
2022-07-03T06:53:41.010722Z  INFO applying new distribution
2022-07-03T06:53:41.011162Z  INFO ✅ success

Which is interesting in that it does not seem to report which wasm-bindgen is being used. So I delete the cached version:

% rm -Rf ~/Library/Caches/dev.trunkrs.trunk/wasm-bindgen-0.2.74

and rerun the build:

2022-07-03T06:57:35.739908Z  INFO processing WASM for vanilla-example
2022-07-03T06:57:35.744409Z  INFO downloading wasm-bindgen version="0.2.74"
2022-07-03T06:57:37.333617Z  INFO installing wasm-bindgen
2022-07-03T06:57:37.386401Z  INFO calling wasm-bindgen for vanilla-example

but wasm-bindgen is in my path:

% which wasm-bindgen
/Users/tinky/.cargo/bin/wasm-bindgen

looking at tools::get it's not immediately obvious why tools::find_system is not finding the binary.

tinkyholloway avatar Jul 03 '22 06:07 tinkyholloway

trunk looks inside the application's Cargo.lock to determine a what version of wasm-bindgen to search for. In the above this resolved to 0.2.74 because the example's Cargo.toml specified:

wasm-bindgen = "=0.2.74"

trunk would then search for this specific version and fail, because the system had a more recent version installed. It would then download the specified version.

If I update the example's Cargo.toml to specify the same version of wasm-bindgen that is installed in the system, then trunk finds this and uses that version as expected.

tinkyholloway avatar Jul 03 '22 08:07 tinkyholloway

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Sep 23 '23 00:09 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Sep 28 '23 00:09 github-actions[bot]