MacOS Mojave 'Ruby/Config. H' File Not Found

MacOS Mojave 'Ruby/Config. H' File Not Found

When I try to build vim(8.1.0509) with ruby support(--enable-rubyinterp) on macOS Mojave(10.14.1) I get error:

In file included from /System/Library/Frameworks/
/System/Library/Frameworks/ fatal error:
      'ruby/config.h' file not found
#include "ruby/config.h"

I have installed Xcode 10.1.

xcode-select -p
/Applications/

Thanks

0

20 Answers

Catalina, Big Sur, etc. (As of 2020 and 2021)

Recent versions of macOS and Xcode (e.g. Catalina 10.15 and Xcode 12.2) definitely have this broken. Reinstalling Xcode and xcode-select --install did not help for me at all (the solutions already posted seem to be outdated). I did not want to use rvm because it may cause some annoying problems.

I did a workaround by manually making a symbolic link:

cd /Applications/
ln -sf ../../../../Headers/ruby/config.h

where ruby/config.h can be found at: /Applications/.

You should change SDK versions (e.g. 11.1 in the above example) accordingly to your current xcode installation.

It is also very likely that one runs into another error where .../universal-darwin19/ruby/config.h cannot be found (Commonmarker gem cannot be installed (needed for jekyll) macos). It can be quick-fixed as follows:

cd /Applications/
ln -sf universal-darwin20 universal-darwin19
9

macOS Catalina

Issue reappeared in Catalina and I wasn't able to spot this package in the Developer SDK. Until better solution found, I was able to workaround this with rubyenv:

brew install rbenv ruby-build
echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile 
rbenv install 2.6.3
rbenv global 2.6.3
Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.