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

Fail to Building native extensions. on Mac OSX 10.13.6 #78

Closed
fascox opened this issue Sep 12, 2018 · 13 comments

Comments

@fascox
Copy link

commented Sep 12, 2018

Building native extensions. This could take a while...
ERROR: Error installing solargraph:
ERROR: Failed to build gem native extension.

current directory: /Library/Ruby/Gems/2.3.0/gems/eventmachine-1.2.7/ext

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180912-38268-nmeu8e.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/eventmachine-1.2.7 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/eventmachine-1.2.7/gem_make.out

@castwide

This comment has been minimized.

Copy link
Owner

commented Sep 12, 2018

It looks like you don't have the Ruby development headers installed. The easiest way I know to get them on OSX is to install XCode.

Relevant links:

https://stackoverflow.com/questions/761521/when-i-try-sudo-gem-install-json-i-get-the-following-error

https://kevinpotgieter.wordpress.com/2012/12/06/ruby-gem-install-mkmf-rb-cant-find-header-files-for-ruby-problem/

@fascox fascox closed this Sep 12, 2018
@fascox fascox reopened this Sep 12, 2018
@fascox

This comment has been minimized.

Copy link
Author

commented Sep 12, 2018

xcode-select --install

and

sudo xcodebuild -license

solve the issue.

@fascox fascox closed this Sep 12, 2018
@acalism

This comment has been minimized.

Copy link

commented Jul 12, 2019

xcode-select --install

and

sudo xcodebuild -license

solve the issue.

After your commands, restarting macOS is required for me.

@xclidongbo

This comment has been minimized.

Copy link

commented Sep 25, 2019

macos 10.14.6.
same error.

@naffan2014

This comment has been minimized.

Copy link

commented Sep 25, 2019

same error

@Calebvh

This comment has been minimized.

Copy link

commented Sep 25, 2019

Same error, (trying to install Jazzy)
current directory: /Library/Ruby/Gems/2.3.0/gems/redcarpet-3.5.0/ext/redcarpet
xcode-select --install
and
sudo xcodebuild -license
and then subsequent restart have not worked, any suggestions?

@castwide

This comment has been minimized.

Copy link
Owner

commented Sep 25, 2019

@Calebvh

This comment has been minimized.

Copy link

commented Sep 25, 2019

Unfortunately I already have them installed, any other ideas?

@castwide

This comment has been minimized.

Copy link
Owner

commented Sep 25, 2019

This might be specific to MacOS 10.14. Apparently some development files got moved, or stopped getting installed by default, or...something. A couple of people have recommended running some variation of this:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

References:

@Calebvh

This comment has been minimized.

Copy link

commented Sep 25, 2019

Yes, I was just about to post.
navigating to that package location and then entering:
sudo installer -pkg macOS_SDK_headers_for_macOS_10.14.pkg -target / 
This did the trick for me, thanks for your help!

@ChrisMash

This comment has been minimized.

Copy link

commented Sep 27, 2019

Running the .pkg in ~/Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg worked for me, so thanks for the tips!

Incidentally a colleague of mine didn't have that packages folder on his machine. I'd install the Xcode 11 update from the App Store and he'd deleted and installed from the download from the apple developer site, so there may be a difference for people if they don't use the App Store (maybe you can get the pkg from the apple developer site downloads page?)

@jasonivers

This comment has been minimized.

Copy link

commented Oct 2, 2019

Installing the package fixed that problem for me, but it's not picking up my RVM ruby version when I do bundle install now... even though ruby --version DOES display it. Any ideas?

@jkuebart

This comment has been minimized.

Copy link

commented Oct 3, 2019

The cause is that Xcode 11 ships the macOS 10.15 SDK which includes headers for ruby2.6, but not for macOS 10.14's ruby2.3. You can verify that this is your problem by running

ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'   

which on macOS 10.14 with Xcode 11 prints the non-existent path

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0

There might still be a macOS 10.14 SDK in /Library/Developer/CommandLineTools/SDKs. It isn't necessary to pollute the system directories by installing the old header files as suggested above. Instead, by pointing the SDKROOT environment variable to it, the appropriate ruby2.3 headers will be found:

SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/
export SDKROOT
ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'

This should now correctly print

/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk//System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0

Likewise, gem install should work when the SDKROOT environment variable is set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.