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

missing pre-compiled arm binary #1405

Closed
shotor opened this issue May 4, 2020 · 81 comments
Closed

missing pre-compiled arm binary #1405

shotor opened this issue May 4, 2020 · 81 comments

Comments

@shotor
Copy link

shotor commented May 4, 2020

Problem description

Can't install grpc-tools on arm architecture (raspberry pi) because of missing precompiled binaries.

node-pre-gyp ERR! stack Error: 404 status code downloading tarball https://node-precompiled-binaries.grpc.io/grpc-tools/v1.8.1/linux-arm64.tar.gz

Is it possible to build these at all?

Reproduction steps

npm init
npm install grpc-tools

Environment

  • Ubuntu 20.04 arm64
  • 10-12-14
  • n
  • grpc-tools, possibly more grpc packages - haven't checked yet

Additional context

error /home/repo/grpc/node_modules/grpc-tools: Command failed.
Exit code: 1
Command: node-pre-gyp install
Arguments:
Directory: /home/repo/grpc/node_modules/grpc-tools
Output:
node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using [email protected]
node-pre-gyp info using [email protected] | linux | arm64
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp info check checked for "/home/repo/grpc/node_modules/grpc-tools/bin/grpc_tools.node" (not found)
node-pre-gyp http GET https://node-precompiled-binaries.grpc.io/grpc-tools/v1.8.1/linux-arm64.tar.gz
node-pre-gyp http 404 https://node-precompiled-binaries.grpc.io/grpc-tools/v1.8.1/linux-arm64.tar.gz
node-pre-gyp ERR! install error
node-pre-gyp ERR! stack Error: 404 status code downloading tarball https://node-precompiled-binaries.grpc.io/grpc-tools/v1.8.1/linux-arm64.tar.gz
node-pre-gyp ERR! stack     at Request.<anonymous> (/home/repo/grpc/node_modules/node-pre-gyp/lib/install.js:149:27)
node-pre-gyp ERR! stack     at Request.emit (events.js:203:15)
node-pre-gyp ERR! stack     at Request.onRequestResponse (/home/repo/grpc/node_modules/request/request.js:1059:10)
node-pre-gyp ERR! stack     at ClientRequest.emit (events.js:198:13)
node-pre-gyp ERR! stack     at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:565:21)
node-pre-gyp ERR! stack     at HTTPParser.parserOnHeadersComplete (_http_common.js:111:17)
node-pre-gyp ERR! stack     at TLSSocket.socketOnData (_http_client.js:451:20)
node-pre-gyp ERR! stack     at TLSSocket.emit (events.js:198:13)
node-pre-gyp ERR! stack     at addChunk (_stream_readable.js:288:12)
node-pre-gyp ERR! stack     at readableAddChunk (_stream_readable.js:269:11)
node-pre-gyp ERR! System Linux 5.4.0-1008-raspi
node-pre-gyp ERR! command "/usr/local/bin/node" "/home/repo/grpc/node_modules/grpc-tools/node_modules/.bin/node-pre-gyp" "install"
node-pre-gyp ERR! cwd /home/repo/grpc/node_modules/grpc-tools
node-pre-gyp ERR! node -v v10.20.1
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok
@Nilos
Copy link

Nilos commented Dec 22, 2020

This is also an issue when running inside Docker on the new MacBook with the M1 Chip.

@antonimmo
Copy link

antonimmo commented Feb 1, 2021

@Nilos Same issue brought me here 👋

Update: I managed to build and run the container by adding --platform linux/amd64 option to both build and run docker commands. You could alternatively specify platform: linux/amd64 for each docker-compose service.

@remko
Copy link

remko commented Feb 18, 2021

Given the introduction of Apple Silicon, and the fact that Docker for Mac on these machines use arm64, does it make sense to re-open this case? Building JS apps that depend on grpc (directly or indirectly) is no longer possible in Docker on Mac (or at least not easy; e.g I can't make the platform trick work with docker-compose, and there are many qemu crashes when running in emulated mode on an M1).

@antonimmo
Copy link

@remko is right, I'd reopen this one. Some issues I came across with just can't be sorted out that easily.

@murgatroid99
Copy link
Member

Our build process runs on GitHub Actions, so adding this is blocked on actions/runner-images#2187.

@sri-vathsa
Copy link

Can anyone share the instructions on how to build the binaries from the source code?

@nicolasnoble
Copy link
Member

Can anyone share the instructions on how to build the binaries from the source code?

Basically https://github.com/grpc/grpc-node/blob/master/packages/grpc-tools/build_binaries.sh

This script probably requires changes, but we have no way of testing on any M1 hardware, so you'd be on your own to change it.

@sri-vathsa
Copy link

sri-vathsa commented Apr 5, 2021

@nicolasnoble @murgatroid99 I am actually using trying to install the grpc-tools on AWS Graviton 2 instances. Are there any instructions on how to run the test cases? I have access to both M1 hardware and Graviton instances. I can run the test cases and share my findings/results.

@shnhrrsn
Copy link

For any on M1 hardware running into this, I was able to workaround it by just forcing the x64 binary and letting Rosetta deal with it:

yarn add grpc-tools --ignore-scripts
pushd node_modules/grpc-tools
node_modules/.bin/node-pre-gyp install --target_arch=x64
popd

Is there any way to include this during normal install?

@murgatroid99
Copy link
Member

I think you can pass the --target_arch=x64 argument directly to npm install. I assume it works the same way with yarn, but I don't use yarn.

@antonimmo
Copy link

@shnhrrsn Also, if you use nvm, you can install x86 node versions following the steps under the "Macs with M1 chip" section of https://github.com/nvm-sh/nvm#macos-troubleshooting. This one solved all my M1 related issues.

@circa10a
Copy link

circa10a commented Jul 7, 2021

ARM binaries should be distributed as part of releases. Especially in 2021. Many cloud providers and personal computer manufacturers are beginning to implement ARM as larger offerings. This is also troublesome for raspberry pi users who would like to run node apps. There isn't a good reason not to pre-compile these binaries, otherwise node marketshare will lessen. I'm already pretty frustrated with it and will be doing less node development as a result.

@circa10a
Copy link

circa10a commented Aug 2, 2021

@murgatroid99
Any chance this group can reconsider?

@murgatroid99
Copy link
Member

I said that making this change is blocked in #1405 (comment). Nothing in the linked issue appears to have changed, so it's still blocked.

@artursapek
Copy link

Our build process runs on GitHub Actions, so adding this is blocked on actions/virtual-environments#2187.

lol that issue is blocking SO many people

@ryanberckmans
Copy link

ryanberckmans commented Aug 21, 2021

We do not intend to distribute ARM binaries for grpc-tools. I suggest generating your code on a different system and then transferring your code to your ARM system instead.

Apple Silicon is here to stay and so is grpc-node. Please reconsider :)

@murgatroid99
Copy link
Member

That comment predates the announcement of Apple Silicon. I wasn't talking about Apple Silicon. As I said in my more recent comments #1405 (comment) and #1405 (comment)

Our build process runs on GitHub Actions, so adding this is blocked on actions/runner-images#2187.

@sebirdman
Copy link

sebirdman commented Nov 6, 2021

I'm curious why there's not a fallback setting to just compile the binaries if no prebuilt exists. Other packages do something similar.

Edit: it appears node-pre-gyp is being abused to just download files. because we're not actually using a binding to node for those tools?

@murgatroid99
Copy link
Member

I disagree with the term "abused". We are using node-pre-gyp to do what it is supposed to do: download binary files for the system the code is running on. It doesn't have a fallback to building locally because it is building protoc, which has an existing build process that uses cmake instead of node-gyp.

@sebirdman
Copy link

Abused might be a strong word, but it's certainly a tad misused. Their docs say it should "stand between" npm and node-gyp. If we can't fallback using the node-gyp to build, i wonder if there's a good way to wrap node-pre-gyp to just auto run ./build_binaries.sh if that fails?

Here's how i got around this without using Rosetta:

  1. clone this repo
  2. install your grpc-tools with yarn install --ignore-scripts
  3. run the script ./build_binaries.sh in the grpc-tools package
  4. copy your files over, something like this:
#!/bin/bash

cp binaries/arm64/protoc node_modules/grpc-tools/bin/protoc
cp binaries/arm64/grpc_node_plugin node_modules/grpc-tools/bin/grpc_node_plugin

@nicolasnoble
Copy link
Member

Think of it more as a stop gap, really. The reality being that building protoc from pure source is impossible due to its bootstrapping nature, and so we can't write a node-gyp installer for it, which requires a very flat list of files to compile, with no intermediate compilation process.

Ideally, node-gyp should support cmake, but that's also not happening: nodejs/node-gyp#1590

Additionally, Apple has made it very difficult to build software on their new M1 hardware when using things like github actions, rendering us basically powerless to create working M1 binaries. So we're stuck between a rock and a hard place here, and there's no good solution unfortunately.

@NixBiks
Copy link

NixBiks commented Nov 11, 2021

This is also an issue when running inside Docker on the new MacBook with the M1 Chip.

Did anyone find a fix when running in Docker?

We have a team that develops in VSCode Remote Containers (ie. docker containers) - some have M1 chips others intel. Any way to support both?

@NixBiks
Copy link

NixBiks commented Nov 11, 2021

@shnhrrsn Also, if you use nvm, you can install x86 node versions following the steps under the "Macs with M1 chip" section of https://github.com/nvm-sh/nvm#macos-troubleshooting. This one solved all my M1 related issues.

@antonimmo That doesn't work when inside a debian-bullseye docker container (on a Mac M1 host) since arch -x86_64 zsh causes an error.

@kakyoism
Copy link

kakyoism commented Dec 1, 2021

Looks like we must build grpc-tools ourselves for Apple Silicon?
I'm a beginner here. Could anybody kindly share a pointer to how to build it locally?

@maschwenk
Copy link

@murgatroid99 I updated to that new version and it worked a treat. Thank you!

@hexnaught
Copy link

Version 1.11.3 now has Mac M1/arm64 binaries.

Updated too and works great now without any work arounds. Thank you! 🙏

@pballester
Copy link

Still missing linux arm64 binary 😢

https://node-precompiled-binaries.grpc.io/grpc-tools/v1.11.3/linux-arm64.tar.gz

@ghost
Copy link

ghost commented Oct 23, 2022

Version 1.11.3 now has Mac M1/arm64 binaries.

Still not available for linux (exp: if you have a docker image):

response status 404 Not Found on https://node-precompiled-binaries.grpc.io/grpc-tools/v1.11.3/linux-arm64.tar.gz

so I've added the following to my dockerfile

RUN npm_config_target_arch=x64 npm i grpc-tools

@ravicious
Copy link

@source-transformer Excuse me, but how does this work? Assuming you have an arm64 Linux image, how is it able to run x64 binaries? Wouldn't that result in an error anyway?

Or do you just install the package but not actually use its components which require x64 binaries?

@ghost
Copy link

ghost commented Oct 24, 2022

Or do you just install the package but not actually use its components which require x64 binaries?

Correct - I should have qualified my answer with - you can't actually run grpc-tools on your container. I had tried the following:

npm_config_target_arch=x86 npm i grpc-tools

In the hopes of getting a binary that potentially could be run. But, honestly that was just a shot in the dark as to the correct label/alias for the 32 bit build/architecture. I wasn't sure how to get a listing of supported architectures.

In my case - it isn't necessary to actually run grpc-tools on my docker container - since those tools are "devDependencies" and their output is actually copied to the docker image.

@huangjun0210
Copy link

Will it support linux arm64 in the future? I'm looking forward to it.

@RedstoneWizard08
Copy link
Contributor

A while back we made an alternative mirror for this...
https://github.com/ZCube/grpc-precompiled-binaries

@huangjun0210
Copy link

A while back we made an alternative mirror for this... https://github.com/ZCube/grpc-precompiled-binaries

How to bulid linux arm64? when I follow with this document: https://github.com/grpc/grpc-node/blob/master/packages/grpc-tools/build_binaries.sh。Error occurred:

...
[ 99%] Linking CXX executable protoc
[100%] Linking CXX executable grpc_node_plugin
/usr/bin/ld: cannot find -lstdc++
collect2: error: ld returned 1 exit status
gmake[2]: *** [grpc_node_plugin] Error 1
gmake[1]: *** [CMakeFiles/grpc_node_plugin.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
[100%] Built target protoc
gmake: *** [all] Error 2

ldconfig -p | less

        libstdc++.so.6 (libc6,AArch64) => /lib64/libstdc++.so.6
        libstdc++.so (libc6,AArch64) => /usr/local/lib/libstdc++.so
        libssl3.so (libc6,AArch64) => /lib64/libssl3.so

@RedstoneWizard08
Copy link
Contributor

I'll have to look again, it's been a while. I know it was pretty simple, though.

@geminiyellow
Copy link

geminiyellow commented Jan 10, 2023

2 years later this issue still open

node-pre-gyp info it worked if it ends with ok | 88s
-- | --
86 | node-pre-gyp info using [email protected] | 88s
87 | node-pre-gyp info using [email protected] \| linux \| x64 | 88s
88 | node-pre-gyp info check checked for "/drone/src/node_modules/grpc-tools/bin/grpc_tools.node" (not found) | 88s
89 | node-pre-gyp http GET https://node-precompiled-binaries.grpc.io/grpc-tools/v1.12.3/linux-x64.tar.gz | 88s
90 | node-pre-gyp ERR! install request to https://node-precompiled-binaries.grpc.io/grpc-tools/v1.12.3/linux-x64.tar.gz failed, reason: read ECONNRESET | 88s
91 | node-pre-gyp ERR! install error

@fatihky
Copy link

fatihky commented Jan 17, 2023

@murgatroid99 and other contributors, are you planning to add support for the arm architecture? if you don't have enough time for that, I'd like to try to add arm support to your library.

@murgatroid99
Copy link
Member

I have no immediate plans to add this myself. If someone contributes a build change that produces ARM binaries for grpc-tools, I will accept it and publish them.

@RedstoneWizard08
Copy link
Contributor

As soon as I remember how I did it, I'll integrate it into the build system and make a PR. (I hope that this message showing up multiple times is just a glitch in the GitHub app on my phone.)

@RedstoneWizard08
Copy link
Contributor

RedstoneWizard08 commented Jan 22, 2023

@murgatroid99 I just finished a patch. https://github.com/RedstoneWizard08/grpc-node
Successful build: https://github.com/RedstoneWizard08/grpc-node/actions/runs/3981949215/jobs/6826020346

PR: #2333

@RedstoneWizard08
Copy link
Contributor

Merged!

@murgatroid99
Copy link
Member

The Linux ARM64 binary is now available in version 1.12.4.

@yurks
Copy link

yurks commented Mar 1, 2023

Version 1.11.3 now has Mac M1/arm64 binaries.

actually it hasn't: #2378

@MehmetSecgin
Copy link

Is it planned to support M2 architecture as well?

@rburdicksuki
Copy link

rburdicksuki commented Jul 17, 2024

The latest version is 1.11.3 and it is on NPM.

Which repo are we talking about here? It sounds like folks have gotten grpc-node to work on Mac M series, is there a concise set of instructions I can follow?

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