Skip to content

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

@fascox

Description

@fascox

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

Activity

castwide

castwide commented on Sep 12, 2018

@castwide
Owner

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/

reopened this on Sep 12, 2018
fascox

fascox commented on Sep 12, 2018

@fascox
Author

xcode-select --install

and

sudo xcodebuild -license

solve the issue.

acalism

acalism commented on Jul 12, 2019

@acalism

xcode-select --install

and

sudo xcodebuild -license

solve the issue.

After your commands, restarting macOS is required for me.

xclidongbo

xclidongbo commented on Sep 25, 2019

@xclidongbo

macos 10.14.6.
same error.

naffan2014

naffan2014 commented on Sep 25, 2019

@naffan2014

same error

Calebvh

Calebvh commented on Sep 25, 2019

@Calebvh

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?

Calebvh

Calebvh commented on Sep 25, 2019

@Calebvh

Unfortunately I already have them installed, any other ideas?

castwide

castwide commented on Sep 25, 2019

@castwide
Owner

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

Calebvh commented on Sep 25, 2019

@Calebvh

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

ChrisMash commented on Sep 27, 2019

@ChrisMash

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

mackworth commented on Nov 12, 2019

@mackworth

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

ccarpita commented on Feb 25, 2020

@ccarpita

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 by xcrun, which should be mostly future-proof:

export SDKROOT=$(xcrun --show-sdk-path)
added a commit that references this issue on Mar 4, 2020
boxabirds

boxabirds commented on May 9, 2020

@boxabirds

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:

Thanks! I'm on 10.14.4 and this was still necessary.

shengyongniu

shengyongniu commented on Jun 14, 2020

@shengyongniu

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

Thank you sir!

mineschan

mineschan commented on Nov 17, 2020

@mineschan

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 by xcrun, which should be mostly future-proof:

export SDKROOT=$(xcrun --show-sdk-path)

Only this solve my issue! Salute Sir!

nomasprime

nomasprime commented on Feb 10, 2021

@nomasprime

Nothing worked for me on 10.15.7.

philippfrank

philippfrank commented on Dec 2, 2021

@philippfrank

None of the above worked on 10.15.7 (Catalina). However, I got it up and running using rbenv:

rbenv global 2.7.4
gem install solargraph
castwide

castwide commented on Dec 5, 2021

@castwide
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @mackworth@nomasprime@boxabirds@jasonivers@fascox

        Issue actions

          Fail to Building native extensions. on Mac OSX 10.13.6 · Issue #78 · castwide/vscode-solargraph