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

Can't get it to run on arm64 (apple m1) #3135

Closed
compojoom opened this issue Jun 21, 2022 · 6 comments
Closed

Can't get it to run on arm64 (apple m1) #3135

compojoom opened this issue Jun 21, 2022 · 6 comments

Comments

@compojoom
Copy link
Contributor

If someone tries to execute:

yarn global add @raiden_network/raiden-cli

on an apple M1 machine the command fails with:

error ~/.config/yarn/global/node_modules/wrtc: Command failed.
Exit code: 1
Command: node scripts/download-prebuilt.js
Arguments:
Directory: ~/.config/yarn/global/node_modules/wrtc
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-gyp@0.13.0
node-pre-gyp info using node@14.18.2 | darwin | arm64
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp info check checked for "~/.config/yarn/global/node_modules/wrtc/build/Release/wrtc.node" (not found)
node-pre-gyp http GET https://node-webrtc.s3.amazonaws.com/wrtc/v0.4.7/Release/darwin-arm64.tar.gz
node-pre-gyp http 404 https://node-webrtc.s3.amazonaws.com/wrtc/v0.4.7/Release/darwin-arm64.tar.gz
node-pre-gyp ERR! install error
node-pre-gyp ERR! stack Error: 404 status code downloading tarball https://node-webrtc.s3.amazonaws.com/wrtc/v0.4.7/Release/darwin-arm64.tar.gz
node-pre-gyp ERR! stack     at Request.<anonymous> (~/.config/yarn/global/node_modules/node-pre-gyp/lib/install.js:149:27)
node-pre-gyp ERR! stack     at Request.emit (events.js:412:35)
node-pre-gyp ERR! stack     at Request.onRequestResponse (~/.config/yarn/global/node_modules/request/request.js:1059:10)
node-pre-gyp ERR! stack     at ClientRequest.emit (events.js:400:28)
node-pre-gyp ERR! stack     at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:647:27)
node-pre-gyp ERR! stack     at HTTPParser.parserOnHeadersComplete (_http_common.js:127:17)
node-pre-gyp ERR! stack     at TLSSocket.socketOnData (_http_client.js:515:22)
node-pre-gyp ERR! stack     at TLSSocket.emit (events.js:400:28)
node-pre-gyp ERR! stack     at addChunk (internal/streams/readable.js:293:12)
node-pre-gyp ERR! stack     at readableAddChunk (internal/streams/readable.js:267:9)
node-pre-gyp ERR! System Darwin 21.5.0
node-pre-gyp ERR! command "~/.nvm/versions/node/v14.18.2/bin/node" "~/.config/yarn/global/node_modules/wrtc/node_modules/.bin/node-pre-gyp" "install"
node-pre-gyp ERR! cwd ~/.config/yarn/global/node_modules/wrtc
node-pre-gyp ERR! node -v v14.18.2

the problem is obviously with the wrtc package. I looked at it and it seems that there hasn't been a new update since January 2021 and that's why there is no binary for arm64. I stumbled across this issue:
node-webrtc/node-webrtc#698

And it turns out that there are user forks that have corrected that problem. In this comment: node-webrtc/node-webrtc#698 (comment) a user even published a new package that contains the necessary binaries.

So, I decided to test if this package will fix the problem. I cloned the repo and changed the wrtc dependency in raiden-cli and raiden-ts to "@koush/wrtc": "^0.5.3",

Afterwards I tried to install. Now the wrtc error was gone, but I got a similar error with the canvas library. Luckily there the community seems to have new releases - they don't have a release with the binaries, but building from source worked after I installed the following dependencies:

brew install pkg-config cairo pango libpng jpeg giflib librsvg

source: Automattic/node-canvas#1733

Now I had to change the require('wrtc') in raiden-cli/src/index.ts to require('@koush/wrtc'). Then I followed the steps in the raiden-cli readme:

yarn install
yarn workspace raiden-ts build # build local dependency
yarn workspace @raiden_network/raiden-cli build # build the dependent output
yarn workspace @raiden_network/raiden-cli build:bundle # build the bundled output

Everything went fine. I tried to to execute the ./raiden command, but was confronted with:

➜ ./raiden --help
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module '.'
Require stack:
- ~/Development/light-client/raiden-cli/raiden
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (~/Development/light-client/raiden-cli/raiden:8:5)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '~/Development/light-client/raiden-cli/raiden' ]
}

No idea why that happens, but I was able to go around that by modifying the raiden file and just using require('bundle'). After that I was able to run the raiden command.

I'm not advising switching to the fork, but posting this here in case anyone else runs into the issue. And maybe the raiden team could think on a better solution to the problem.

@taleldayekh
Copy link
Contributor

@netcriptus Do you have a M1 machine? If not can you try this out on maybe @DinaBB machine in the office? I asked @karlb to support in debugging this tomorrow so would be good if you can collaborate on this.

@netcriptus
Copy link
Contributor

No, mine is an Intel i5

@compojoom
Copy link
Contributor Author

So the module not found error was resolved by downgrading inquirer:
#3150

The wrtc problem remains. As pointed out above I'm able to run the code by switching wrtc to @koush/wrtc

@taleldayekh
Copy link
Contributor

@compojoom @andrevmatos Is this still relevant or can I close?

@andrevmatos
Copy link
Contributor

It's still relevant. We'll be checking for options on providing wrtc library for M1 macs or replacing the library (the API is standardised) and how to ensure a seamless cross-platform experience.

@andrevmatos
Copy link
Contributor

Fixed in latest releases (linked above).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants