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

How to install for different architectures? #138

Closed
chetbox opened this issue May 7, 2024 · 4 comments
Closed

How to install for different architectures? #138

chetbox opened this issue May 7, 2024 · 4 comments
Assignees

Comments

@chetbox
Copy link

chetbox commented May 7, 2024

When building for Electron it's possible to build for different architectures, for example:

electron-forge make --arch arm64

For this to work any native modules must be installed for the target architecture. This can be achieved with npm:

npm install --target_arch=arm64

or with yarn:

npm_config_target_arch=arm64 npm_config_target_platform=linux yarn install --force

This works for various modules such as serialport and lzma-native but not for @ngrok/ngrok. How can I force npm or (preferably) yarn to install another architecture such as @ngrok/ngrok-linux-arm64-gnu on a Linux x64 machine?

In our case the build is running on GitHub Actions. I do not have the same problem with building for multiple architectures on macOS because a Darwin "universal" binary is installed.

@bobzilladev
Copy link
Contributor

Hello, thanks for writing in!

At first glance it looks like both lzma-native and serialport include all prebuilds by default, rather than as separate subpackages like this SDK does, as you mention. One option to deal with this would be to reference the subpackages directly, and have it ignore the platform check with force. For instance npm i @ngrok/ngrok-darwin-x64 --force will pull the darwin package down on a linux host. We can look into what it would take for yarn to do a similar behavior, but hopefully the npm path would be able to solve for this use-case? Please let us know if that isn't the case or you run into additional hurdles!

@bobzilladev bobzilladev self-assigned this May 9, 2024
@chetbox
Copy link
Author

chetbox commented May 9, 2024

I see! I tried a few things like using Docker run yarn install --force but I ran into a number of problems, especially on GitHub actions.

It seems the sub packages of @ngrok/ngrok include prebuilt .node binaries so actually using Docker isn't necessary. For now, my workaround is to use yarn install --ignore-platform to install the packages for all platforms and architectures.

I would have expected setting npm_config_target_arch to work but I don't understand enough about how NPM/Yarn work to know if I'm misunderstanding.

@bobzilladev
Copy link
Contributor

Ah, it looks like yarn may have stopped supporting npm_config_ settings? yarnpkg/yarn#7629 (comment)

It's great that you found a workaround that will get the job done, all the sub-packages do include the binary, and the main package determines which one to use. Let us know if you run into any other issues!

@bobzilladev
Copy link
Contributor

We'll go ahead and close this ticket out, feel free to reopen if you run into other issues. Thanks for writing in!

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

2 participants