Skip to content

Error installing grpc gem on M4 MacBook #39363

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

Closed
kefiriaus opened this issue Apr 24, 2025 · 10 comments
Closed

Error installing grpc gem on M4 MacBook #39363

kefiriaus opened this issue Apr 24, 2025 · 10 comments

Comments

@kefiriaus
Copy link

kefiriaus commented Apr 24, 2025

What version of gRPC and what language are you using?

Version: grpc 1.69.0
Language: ruby 3.4.2 (2025-02-15 revision d2930f8e7a) +PRISM [x86_64-darwin24]

What operating system (Linux, Windows,...) and version?

MacOS Sequoia 15.3.1 (24D70)

What runtime / compiler are you using (e.g. python version or version of gcc)

Python 3.9.6
Apple clang version 17.0.0 (clang-1700.0.13.3)
Target: x86_64-apple-darwin24.3.0

What did you do?

Please provide either 1) A unit test for reproducing the bug or 2) Specific steps for us to follow to reproduce the bug. If there’s not enough information to debug the problem, gRPC team may close the issue at their discretion. You’re welcome to re-open the issue once you have a reproduction.

  1. Make iTerm workin through Rosetta
  2. Install mice
  3. Install ruby 3.4.2
  4. gem install grpc -v '1.69.0'
  5. Got error

What did you expect to see?

grpc gem successfully installed

What did you see instead?

gem_make.txt

Main error as I see

In file included from third_party/zlib/zutil.c:10:
In file included from third_party/zlib/gzguts.h:20:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:61:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:316:7: error: expected identifier or '('
  316 | FILE    *fdopen(int, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_3_2, __DARWIN_EXTSN(fdopen));
      |          ^
third_party/zlib/zutil.h:147:33: note: expanded from macro 'fdopen'
  147 | #        define fdopen(fd,mode) NULL /* No fdopen() */
      |                                 ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_null.h:26:16: note: expanded from macro 'NULL'
   26 | #define NULL ((void*)0)
      |                ^
In file included from third_party/zlib/zutil.c:10:
In file included from third_party/zlib/gzguts.h:20:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:61:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:316:7: error: expected ')'
third_party/zlib/zutil.h:147:33: note: expanded from macro 'fdopen'
  147 | #        define fdopen(fd,mode) NULL /* No fdopen() */
      |                                 ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_null.h:26:16: note: expanded from macro 'NULL'
   26 | #define NULL ((void*)0)
      |                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:316:7: note: to match this '('
third_party/zlib/zutil.h:147:33: note: expanded from macro 'fdopen'
  147 | #        define fdopen(fd,mode) NULL /* No fdopen() */
      |                                 ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include/__stddef_null.h:26:15: note: expanded from macro 'NULL'
   26 | #define NULL ((void*)0)
      |               ^
In file included from third_party/zlib/zutil.c:10:
In file included from third_party/zlib/gzguts.h:20:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/stdio.h:61:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:316:7: error: expected ')'
  316 | FILE    *fdopen(int, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_3_2, __DARWIN_EXTSN(fdopen));
      |          ^
third_party/zlib/zutil.h:147:33: note: expanded from macro 'fdopen'
  147 | #        define fdopen(fd,mode) NULL /* No fdopen() */

Anything else we should know about your project / environment?

Already tried:

  • reinstall Xcode-tools
  • set/unset force_ruby_platform
  • setting flags
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"
export PKG_CONFIG_PATH="/usr/local/opt/zlib/lib/pkgconfig"
export GRPC_DISABLE_THIRD_PARTY_ZLIB=1
  • install gem with gem install grpc -- --with-zlib-dir=/usr/local/opt/zlib
@kefiriaus kefiriaus changed the title Error while installing grpc gem on M4 MacBook Error installing grpc gem on M4 MacBook Apr 24, 2025
@stefanwork
Copy link

I'm having the same problem. Looks like it has something to do with Command Line Tools for Xcode 16.3, since downgrading to 16.2 fixes it.

The workaround that works for me is:

  1. Log in with an Apple account here: https://developer.apple.com/download/all/
  2. Download and install version 16.2 of the Command Line Tools for Xcode: https://download.developer.apple.com/Developer_Tools/Command_Line_Tools_for_Xcode_16.2/Command_Line_Tools_for_Xcode_16.2.dmg
  3. Try installing the gem again.

@kefiriaus
Copy link
Author

@stefanwork Thank you, I also understood that Command Line Tools not compatible with zlib 1.3 that is used in grpc 1.69.0 (also in newer versions, as I've tried them all)

As I see in 1.72.0 zlib was updated to v1.3.1 but this version is not in rubygems.org yet.

I also tried some downgrade of the Command Line Tools to v15 but it did not work and I did not think that only one minor version will do the trick, thx again for sharing your way.

After three nights of trying and asking Ai and searching google I ended up with coping this compiled gem from other MacBook and its finally worked earlier today.

@chadlwilson
Copy link
Contributor

chadlwilson commented Apr 25, 2025

Or better yet, avoid having to compile from source at all by installing 1.70.1 onwards where the gems are precompiled for Ruby 3.4 and should install near instantly as long (as you’re not forcing use of ‘Ruby’ platform only)

1.69 predates Ruby 3.4 so by definition the gems are not precompiled.

@chadlwilson
Copy link
Contributor

Any fix that needs to be made here is not going to be backported to 1.69.x anyway (from what I have seen of grpc releases, although I am not a maintainer) so you’re going to have to try with newer versions anyway.

@chadlwilson
Copy link
Contributor

As a side note, why would you want to install x64 versions of gems via Rosetta if you have an Apple Silicon M4 macbook, rather than using aarch64 gems, or trying to compile for that platform at least?

@jasonpenny
Copy link

jasonpenny commented Apr 25, 2025

I found a workaround by installing an old version of the LLVM toolchain from homebrew (https://brew.sh/):

$ brew install llvm@17

$ export PATH="$(brew --prefix llvm@17)/bin:$PATH"
$ export CC=clang
$ export CXX=clang++
$ export LDFLAGS="-L$(brew --prefix llvm@17)/lib"
$ export CPPFLAGS="-I$(brew --prefix llvm@17)/include"

$ gem install grpc --platform=ruby --version 1.69.0
Building native extensions. This could take a while...
Successfully installed grpc-1.69.0
Parsing documentation for grpc-1.69.0
Installing ri documentation for grpc-1.69.0
Done installing documentation for grpc after 8 seconds
1 gem installed

@kefiriaus
Copy link
Author

@jasonpenny Hm, also tried these steps, didn't work for me.

@oleg-vinted
Copy link

oleg-vinted commented Apr 30, 2025

Here's what worked for us:

  1. sudo rm -rf /Library/Developer/CommandLineTools
  2. Log in with an Apple account here: https://developer.apple.com/download/all/
  3. Download and install version 16.2 of the Command Line Tools for Xcode: https://download.developer.apple.com/Developer_Tools/Command_Line_Tools_for_Xcode_16.2/Command_Line_Tools_for_Xcode_16.2.dmg
  4. Reinstall the affected Ruby 3.4.x version: e.g. mise uninstall ruby@3.4.2 then mise install ruby@3.4.2
  5. Reinstall grpc: gem install grpc -v 1.64.3 or bundle install

Notes

Not sure if step 1 is necessary, I've done this to make sure there is no trace of the old toolchain left.

Steps 2 and 3 are copied from #39363 (comment).

Reinstalling Ruby (step 4) is necessary if you've built Ruby 3.4 using the newest Command Line Tools and you get errors like this after toolchain downgrade:

In file included from rb_byte_buffer.c:19:
In file included from /Users/vm/.local/share/mise/installs/ruby/3.4.2/include/ruby-3.4.0/ruby/ruby.h:42:
In file included from /Users/vm/.local/share/mise/installs/ruby/3.4.2/include/ruby-3.4.0/ruby/internal/memory.h:64:
/Users/vm/.local/share/mise/installs/ruby/3.4.2/include/ruby-3.4.0/ruby/internal/stdckdint.h:48:11: error: 'stdckdint.h' file not found with <angled> include; use "quotes" instead
   48 | # include <stdckdint.h>
      |           ^~~~~~~~~~~~~
      |           "stdckdint.h"

@stefanwork
Copy link

Version 1.72.0 was released today and it resolves this issue for me.

@alto-ruby
Copy link
Contributor

Close as user verified fixed in 1.72.0

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

7 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy