Yosemite upgrade broke ruby.h
Asked Answered
R

9

23

Ever since upgrading to Yosemite, I get this error trying to build anything that includes ruby.h:

In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby.h:33:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found
#include "ruby/config.h"
         ^
1 error generated.
make[1]: *** [objects/if_ruby.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [first] Error 2

And sure enough, /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/config.h is indeed missing.

$ ls -laF /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/
total 72
drwxr-xr-x  21 root  wheel    714 Jul 29 21:56 ./
drwxr-xr-x   5 root  wheel    170 Jul 29 21:56 ../
drwxr-xr-x   7 root  wheel    238 Jul 29 21:56 backward/
-rw-r--r--   2 root  wheel   3360 Sep 21 15:25 debug.h
-rw-r--r--   2 root  wheel   5553 Sep 21 15:25 defines.h
-rw-r--r--   2 root  wheel    881 Sep 21 15:25 digest.h
-rw-r--r--   2 root  wheel   7628 Sep 21 15:25 dl.h
-rw-r--r--   2 root  wheel  14123 Sep 21 15:25 encoding.h
-rw-r--r--   2 root  wheel  32904 Sep 21 15:25 intern.h
-rw-r--r--   2 root  wheel   5869 Sep 21 15:25 io.h
-rw-r--r--   2 root  wheel   4522 Sep 21 15:25 missing.h
-rw-r--r--   2 root  wheel  37617 Sep 21 15:25 oniguruma.h
-rw-r--r--   2 root  wheel   1502 Sep 21 15:25 re.h
-rw-r--r--   2 root  wheel    890 Sep 21 15:25 regex.h
-rw-r--r--   2 root  wheel  49734 Sep 21 15:25 ruby.h
-rw-r--r--   2 root  wheel   4651 Sep 21 15:25 st.h
-rw-r--r--   2 root  wheel    374 Sep 21 15:25 subst.h
-rw-r--r--   2 root  wheel   1102 Sep 21 15:25 thread.h
-rw-r--r--   2 root  wheel   2139 Sep 21 15:25 util.h
-rw-r--r--   2 root  wheel   1968 Sep 21 15:25 version.h
-rw-r--r--   2 root  wheel   1794 Sep 21 15:25 vm.h

Did the install accidentally a file? Does Yosemite just ship with a busted Ruby header file set?

What's the best way to fix this? Can I just unpack the source code in there to get the right headers?

Rosel answered 17/10, 2014 at 23:13 Comment(4)
Did you reinstall the Xcode tools? System upgrades have been known to force that need.Nickey
I reinstalled the Xcode command line tools, but still don't have a ruby/config.hRosel
I don't think you have the correct Xcode installed. Note the directory in the path: MacOSX10.9.sdk I'd expect to see something about 10.10.Inkwell
CDub! Awesome. I reinstalled Xcode 6.0.1, and now it seems to work, and pulls ruby.h from a completely different location. Thanks for the tip!Rosel
S
18

One note on this: I ran into this problem after upgrading to "OS X El Capitan". I installed the command line tools by running 'xcode-select --install'. After that, my ruby build environment started working again.

Senseless answered 18/10, 2015 at 19:44 Comment(0)
F
17

For those who already had Xcode installed from the Apple developers site, running xcode-select --install doesn't work, since it will say that Xcode is already installed (Xcode already comes with the CommandLineTools bundled).

In my case, I fixed it by downloading the corresponding CommandLineTools from the same place, executing it, then going to /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg and executing it too.

Filagree answered 7/11, 2018 at 17:1 Comment(0)
O
16
cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby
sudo ln -s ../universal-darwin15/ruby/config.h ./config.h

updates Nicholas Tsipanov's answer from 2014-10-18.

Otway answered 26/10, 2015 at 3:56 Comment(2)
This is not working for me on OS X El Capitan 10.11.6; No such file or directory. I had to run 'xcode-select --install' as described by Jesus instead.Inception
Maybe your MacOSX10.11.sdk or universal-darwin15 needs to be the correct path. It worked for me after ensuring correct path.Warrior
V
12

I got the same error, but installed "Command Line Tools (OS X 10.10) for Xcode - Xcode 6.1" and installing worked fine after that.

Virtuous answered 20/10, 2014 at 12:15 Comment(0)
C
6

If you use Homebrew, brew install ruby is a fast workaround (it gets you a brand new ruby installation distinct from the one from Xcode).

Claymore answered 23/5, 2016 at 14:30 Comment(3)
@AboozarRajabi echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc if you are on bash or some other shell where you will want to pipe it elsewhere.Leishaleishmania
Thanks, I solved the problem by upgrading Ruby and also Rails to the latest versions (missing gems are reinstalled)Scholz
Wouldn't this potentially break other programs that assume you're using the version that comes with the OS?Filagree
I
4

Try this:

cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby
sudo ln -s ../universal-darwin13/ruby/config.h ./config.h
Ibis answered 18/10, 2014 at 17:3 Comment(0)
R
1

Xcode got messed up in the upgrade somehow.

I opened Xcode (which I never do otherwise) and it complained about all sorts of missing components. So I let it go ahead and fix itself, and now all is well.

Props to CDub in the comments on OP for pointing to this as a potential source of weirdness.

Rosel answered 18/10, 2014 at 16:30 Comment(0)
C
1

I am running Mojave 10.14.6. The answer here fixed the subject issue for me: https://mcmap.net/q/176141/-docker-for-mac-mkmf-rb-can-39-t-find-header-files-for-ruby

Solution:

sudo rm -rf /Library/Developer/CommandLineTools
xcode-select --install
sudo xcodebuild -license accept
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg 
Curvet answered 5/1, 2020 at 23:23 Comment(0)
M
0

Fixed by pointing to correct path for Xcode developer tools.

Error before (Note the path to Xcode711.app instead of Xcode.app)

/Applications/Xcode711.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/include/ruby-2.0.0/ruby/ruby.h:24:10:

Ran

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
Mouseear answered 2/1, 2017 at 9:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.