Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gem install - fatal error: 'ruby/config.h' file not found in Mojave

gem install is failing in MacOs Mojave. Anything that can help me solve this? My ruby version is ruby 2.3.7p456.

➜ sudo gem install json -v '1.8.3'    current directory: /Library/Ruby/Gems/2.3.0/gems/json-1.8.3/ext/json/ext/generator make "DESTDIR=" compiling generator.c In file included from generator.c:1: In file included from ./../fbuffer/fbuffer.h:5: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby.h:33: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found #include "ruby/config.h"          ^~~~~~~~~~~~~~~ 1 error generated. make: *** [generator.o] Error 1  make failed, exit code 2 
like image 635
SpaceX Avatar asked Jul 10 '18 11:07

SpaceX


1 Answers

Update 15/03/2021

According to Apple, Ruby won't be included anymore in future versions of the system, so using a Ruby version manager will be the only way to go once this will actually happen.


Original answer

After hours and hours of trial and errors I wanted to go deeper into the reasons of this error and I finally found this that I think is the clean way to go around this issue:

Catalina (NdMe: I think this started earlier, on Mojave) no longer supports including macOS headers in command line tools, they have to be explicitly used through Xcode SDK. You can do so by running gem through the xcrun tool like:

xcrun gem install <your_gem>

Quoted from a Github issue comment.

like image 129
Cristina De Rito Avatar answered Sep 26 '22 21:09

Cristina De Rito