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

Errors building Optic on Apple M1 Machine #603

Closed
smizell opened this issue Feb 17, 2021 · 1 comment
Closed

Errors building Optic on Apple M1 Machine #603

smizell opened this issue Feb 17, 2021 · 1 comment
Assignees

Comments

@smizell
Copy link
Contributor

smizell commented Feb 17, 2021

I was trying to install, build, and run the Optic code as per the Developer Setup doc. I have an Apple M1 and got two different errors related to the platform.

Error with wasm-pack

When running yarn install, I received this error below which pertains to this issue.

error /.../optic/node_modules/wasm-pack: Command failed.
Exit code: 1
Command: node ./install.js
Arguments:
Directory: /.../optic/node_modules/wasm-pack
Output:
/.../optic/node_modules/wasm-pack/binary.js:19
  throw new Error(`Unsupported platform: ${type} ${arch}`);
  ^

Error: Unsupported platform: Darwin arm64
    at getPlatform (/.../optic/node_modules/wasm-pack/binary.js:19:9)
    at getBinary (/.../optic/node_modules/wasm-pack/binary.js:23:20)
    at install (/.../optic/node_modules/wasm-pack/binary.js:37:18)
    at Object.<anonymous> (/.../optic/node_modules/wasm-pack/install.js:4:1)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:973:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)

To fix, I did the following:

  • Removed the wasm-pack dev dependency in the packages.json
  • Installed wasm-pack with cargo install wasm-pack
  • Reran yarn install

Error with wasm-opt

When running optic_build, I the following issue.

 | [INFO]: Installing wasm-bindgen...
 | Error: no prebuilt wasm-opt binaries are available for this platform: Unrecognized target!
 | To disable `wasm-opt`, add `wasm-opt = false` to your package metadata in your `Cargo.toml`.
 | npm ERR! code 1
 | npm ERR! path /.../optic/workspaces/diff-engine-wasm
 | npm ERR! command failed
 | npm ERR! command sh -c cd engine && wasm-pack build --target nodejs --out-dir build --out-name index

I followed the suggestion in the error response and added wasm-opt = false to my package metadata. This fixed the issue and I was able to run optic_build, optic_watch, and yarn start-local.

@LouManglass LouManglass self-assigned this Feb 18, 2021
@JaapRood
Copy link
Contributor

JaapRood commented Feb 18, 2021

Hey @smizell, thanks for posting the issue. I also occasionally develop Optic on an M1 Mac (as the only one of the Optic team so far) and have found the exact same problem as you did, using the exact same workarounds.

Both problems stem from there being no prebuilt binary published for Darwin-aarch64. There are issues and a PR that should fix that, but it's hard to say how long that's going to take to get merged. Ever since the October last year the project has seen a build up of a backlog with little activity (connected to lay-offs at Mozilla perhaps?). Once these binaries are published, installing wasm-pack through NPM / Yarn should work just fine.

With that in mind, I reckon sticking with the workaround is the way to go for at least a while.

@LouManglass LouManglass changed the title Errors running Optic on Apple M1 Machine Errors building Optic on Apple M1 Machine Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants