wasm-pack: Bad CPU type in executable (os error 86) running wasm-pack build on M1
🐛 Bug description
wasm-pack build on M1 failed: Bad CPU type in executable (os error 86)
❯ wasm-pack build
[INFO]: 🎯 Checking for the Wasm target…
[INFO]: 🌀 Compiling to Wasm…
Compiling proc-macro2 v1.0.34
Compiling unicode-xid v0.2.2
Compiling wasm-bindgen-shared v0.2.78
Compiling syn v1.0.84
Compiling log v0.4.14
Compiling cfg-if v1.0.0
Compiling lazy_static v1.4.0
Compiling bumpalo v3.8.0
Compiling wasm-bindgen v0.2.78
Compiling quote v1.0.10
Compiling wasm-bindgen-backend v0.2.78
Compiling wasm-bindgen-macro-support v0.2.78
Compiling wasm-bindgen-macro v0.2.78
Compiling console_error_panic_hook v0.1.7
Compiling wasm-game-of-life v0.1.0 (/Users/welson/git/wasm-game-of-life)
warning: function is never used: set_panic_hook
–> src/utils.rs:1:8
|
1 | pub fn set_panic_hook() {
| ^^^^^^^^^^^^^^
|
= note: #[warn(dead_code)] on by default
warning: wasm-game-of-life (lib) generated 1 warning
Finished release [optimized] target(s) in 4.56s
[INFO]: ⬇️ Installing wasm-bindgen…
Error: Bad CPU type in executable (os error 86)
On x64:
[INFO]: Installing wasm-bindgen…
[INFO]: Optimizing wasm binaries with wasm-opt…
[INFO]: Optional fields missing from Cargo.toml: ‘description’, ‘repository’, and ‘license’. These are not necessary, but recommended
[INFO]: 😃 Done in 8.75s
[INFO]: 😃 Your wasm pkg is ready to publish at /usr/src/myapp/wasm-game-of-life/pkg.
👟 Steps to reproduce
Installed wasm-pack via homebrew Follow https://rustwasm.github.io/book/game-of-life/hello-world.html
🌍 Your environment
Include the relevant details of your environment. wasm-pack version: wasm-pack 0.10.2 rustc version: rustc 1.56.1 (59eed8a2a 2021-11-01)
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17
Workaround: (manually install wasm-bindgen)
❯ wasm-pack build [INFO]: 🎯 Checking for the Wasm target… [INFO]: 🌀 Compiling to Wasm… warning: function is never used:
set_panic_hook–> src/utils.rs:1:8 | 1 | pub fn set_panic_hook() { | ^^^^^^^^^^^^^^ | = note:#[warn(dead_code)]on by defaultwarning:
wasm-game-of-life(lib) generated 1 warning Finished release [optimized] target(s) in 0.01s [INFO]: Optional fields missing from Cargo.toml: ‘description’, ‘repository’, and ‘license’. These are not necessary, but recommended [INFO]: ✨ Done in 0.17s [INFO]: 📦 Your wasm pkg is ready to publish at /Users/welson/git/wasm-game-of-life/pkg.For me
softwareupdate --install-rosettainstalling rosetta worked.This worked for me after my
wasm-packwas rendered useless after my macOS upgrade to Monterey12.5.1disabled Rosetta. My symptom wasSo I ran
cargo uninstall wasm-packcargo install wasm-bindgen-clibrew install binaryencargo install wasm-packI’m not sure Steps 1 and 4 were necessary; that’s just how I did them. Now I’m back in business.
Thank you for providing a fix for now, on one of my M1 machines with a slightly older version of wasm-pack this isn’t necessary but on
0.10.2it is.Also just for anyone else looking at this, the package is
binaryenCurrently I’m using
wasm-bindgen-cli+wasm-optinstead ofwasm-pack. It works well for me in my arm64 macos.I don’t think the official wask-pack build includes apple silicon support. Just type the 2 commands for workaround: