-
Notifications
You must be signed in to change notification settings - Fork 24
Closed
Description
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
sashao and clarkyi
Activity
castwide commentedon 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 commentedon Sep 12, 2018
xcode-select --install
and
sudo xcodebuild -license
solve the issue.
acalism commentedon Jul 12, 2019
After your commands, restarting macOS is required for me.
xclidongbo commentedon Sep 25, 2019
macos 10.14.6.
same error.
naffan2014 commentedon Sep 25, 2019
same error
Calebvh commentedon 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 commentedon Sep 25, 2019
You might need to install the command line tools: https://kevinpotgieter.wordpress.com/2012/12/06/ruby-gem-install-mkmf-rb-cant-find-header-files-for-ruby-problem/
Calebvh commentedon Sep 25, 2019
Unfortunately I already have them installed, any other ideas?
castwide commentedon 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:
References:
Calebvh commentedon 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 commentedon 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?)
5 remaining items
mackworth commentedon Nov 12, 2019
For me (Xcode 11 on Mojave as well),
gem install
didn't seem to use the SDKROOT, even though RBConfig returned the right value. This suggestion on StackOverflow worked instead, so I'm passing it on here:sudo xcode-select --switch /Library/Developer/CommandLineTools
and then restore afterwards with
sudo xcode-select --switch /Applications/Xcode.app
Reference: https://stackoverflow.com/a/58231417/580850
ccarpita commentedon Feb 25, 2020
If you are on OSX 10.15+, the headers package is no longer available. I fixed this issue by setting
SDKROOT
in my shell configuration to the value provided byxcrun
, which should be mostly future-proof:Issue I encountered with install
boxabirds commentedon May 9, 2020
Thanks! I'm on 10.14.4 and this was still necessary.
shengyongniu commentedon Jun 14, 2020
Thank you sir!
mineschan commentedon Nov 17, 2020
Only this solve my issue! Salute Sir!
nomasprime commentedon Feb 10, 2021
Nothing worked for me on 10.15.7.
philippfrank commentedon Dec 2, 2021
None of the above worked on
10.15.7
(Catalina). However, I got it up and running usingrbenv
:castwide commentedon Dec 5, 2021
Ruby on MacOS is frequently problematic, especially if you're using whatever janky version of Ruby ships with the OS, which often does not include the stuff you need to natively compile depenencies like Nokogiri. The problems are not limited to Solargraph. One common solution is to use rbenv, which Solargraph makes an effort to support.