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

Failed to build gem native extension #133

Closed
eduOSS opened this issue Apr 18, 2015 · 22 comments
Closed

Failed to build gem native extension #133

eduOSS opened this issue Apr 18, 2015 · 22 comments
Labels

Comments

@eduOSS
Copy link

eduOSS commented Apr 18, 2015

Hello, all

I met a snag as the following:

root@ubuntu:/home/eduOSS# gem install github-pages
Building native extensions.  This could take a while...
ERROR:  Error installing github-pages:
    ERROR: Failed to build gem native extension.

    /usr/bin/ruby2.1 -r ./siteconf20150418-11838-636jct.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.1.0/gems/fast-stemmer-1.0.2 for inspection.
Results logged to /var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/fast-stemmer-1.0.2/gem_make.out

The version of Ruby installed is ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux-gnu]

Could anyone please tell me why and how to tackle it? Thanks very much.

@parkr
Copy link
Contributor

parkr commented Apr 18, 2015

Did you also install the development headers? They don't seem to be present:

mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

@eduOSS
Copy link
Author

eduOSS commented Apr 18, 2015

Do you mean installing ruby-dev? But the error remains the same after that step...

apt-get install ruby-dev

@parkr
Copy link
Contributor

parkr commented Apr 19, 2015

You need the Ruby 2.1 dev headers. Maybe @envygeeks would know more on how to get them...

@envygeeks
Copy link

sudo apt-get install ruby2.1-dev for 2.1.

@eduOSS
Copy link
Author

eduOSS commented Apr 20, 2015

Err http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu/ trusty/main ruby2.1-dev amd64 2.1.5-1bbox1~trusty1
  404  Not Found
Selecting previously unselected package libgmpxx4ldbl:amd64.
(Reading database ... 205109 files and directories currently installed.)
Preparing to unpack .../libgmpxx4ldbl_2%3a5.1.3+dfsg-1ubuntu1_amd64.deb ...
Unpacking libgmpxx4ldbl:amd64 (2:5.1.3+dfsg-1ubuntu1) ...
Selecting previously unselected package libgmp-dev:amd64.
Preparing to unpack .../libgmp-dev_2%3a5.1.3+dfsg-1ubuntu1_amd64.deb ...
Unpacking libgmp-dev:amd64 (2:5.1.3+dfsg-1ubuntu1) ...
E: Failed to fetch http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu/pool/main/r/ruby2.1/ruby2.1-dev_2.1.5-1bbox1~trusty1_amd64.deb  404  Not Found

Oops,,,

@envygeeks
Copy link

There is something wrong with your apt source, Brightbox Ruby does have ruby2.1-dev but you can't even reach it, which leads me to believe you need to remove the source and readd it.

@martinbean
Copy link

I get this error when running sudo gem update github-pages. Is this related?

Updating installed gems
Updating github-pages
Building native extensions. This could take a while...
ERROR: Error installing github-pages:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
creating Makefile

make "DESTDIR="
make: *** No rule to make target /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/universal-darwin14/ruby/config.h', needed by autolink.o'. Stop.

Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/redcarpet-3.3.2 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/redcarpet-3.3.2/ext/redcarpet/gem_make.out
Nothing to update

My Ruby version when running ruby -v is reported as:

ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]

@parkr
Copy link
Contributor

parkr commented Sep 28, 2015

@martinbean Related, yes, but on a different platform.

See jekyll/jekyll#3999 and jekyll/jekyll#3984

@martinbean
Copy link

@parkr Strange. I’m not running El Capitan (still on Mavericks).

@parkr
Copy link
Contributor

parkr commented Sep 28, 2015

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/universal-darwin14/ruby/config.h

Check out the SDK version in that stack trace.

@parkr
Copy link
Contributor

parkr commented Jan 25, 2016

Closing as stale.

@parkr parkr closed this as completed Jan 25, 2016
@parkr parkr added the question label Jan 25, 2016
@Darshnik
Copy link

Darshnik commented Apr 5, 2016

if using ruby version 2.2 or greater you need to have ruby2.2-dev

sudo apt-get install ruby2.2-dev

@donli1210
Copy link

You might take a look

http://stackoverflow.com/a/34671499/2597259

@midacts
Copy link

midacts commented Jan 17, 2017

I am having a similar error on RHEL 7. I have also installed ruby-devel and am receving this error:

gem install tiny_tds --source http://rubygems.org
Building native extensions. This could take a while...
ERROR: Error installing tiny_tds:
ERROR: Failed to build gem native extension.

/opt/rh/rh-ruby22/root/usr/bin/ruby -r ./siteconf20170117-3957-1fbskki.rb extconf.rb

mkmf.rb can't find header files for ruby at /opt/rh/rh-ruby22/root/usr/share/include/ruby.h

extconf failed, exit code 1

@parkr
Copy link
Contributor

parkr commented Jan 17, 2017

@midacts It looks like you're using a custom version of Ruby installed to /opt/rh/rh-ruby22/root/usr. Installing ruby-devel won't install the headers into this location, but into /usr/share/include/ruby.h instead. You will need to install the headers for the binary located at /opt/rh/rh-ruby22/root/usr/bin/ruby.

@inscrutabledude
Copy link

Hi @parkr Could you elaborate on how to do that? I'm a complete ruby noob, I'm just trying to get the knife-azure gem installed for chef, and am getting this message: current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.7.0.1/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20170220-10621-ejv836.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

I tried this command: sudo apt-get install ruby2.3-dev
Then tried to install gem again, got: E: Unable to locate package ruby2.3.0-dev

Any advice appreciated!

gaganawhad added a commit to gaganawhad/dotfiles that referenced this issue Jun 20, 2017
Here are some documents that came in handy:
  - I use vim 8 style of managing packages: https://shapeshed.com/vim-packages/
  - I had to use rvm use system to install command T in order that it would use
    the system ruby to install it wincent/command-t#214 (comment)
  - I had to install ruby2.3-dev github/pages-gem#133 (comment)
  - In order to install command t you have to do something either `rake make` or use
    `make clean; ruby extconf.rb && make`
@BruceChen5683
Copy link

I've installed git for windows,JRuby,rjgit and gollum serval days ago,and they work well. But gollum doesn't recognize the form of table.When i install github-markdown by the command of gem install github-markdown,the error comes.

gem install github-markdown
Building native extensions. This could take a while...
ERROR:  Error installing github-markdown:
        ERROR: Failed to build gem native extension.

@salmanfarisvp
Copy link

salmanfarisvp commented Dec 4, 2017

I got error while installing gem install github-pages

error log


Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions.  This could take a while...
ERROR:  Error installing github-pages:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/commonmarker-0.17.6/ext/commonmarker
C:/Ruby24-x64/bin/ruby.exe -r ./siteconf20171204-5804-1t48xd0.rb extconf.rb
checking for cmake... yes
CMake Error: CMake was unable to find a build program corresponding to "MSYS Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MSYS Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_AR was not found, please set to archive program.
-- Configuring incomplete, errors occurred!
make libcmark-gfm_static failed
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby24-x64/bin/$(RUBY_BASE_NAME)

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  C:/Ruby24-x64/lib/ruby/gems/2.4.0/extensions/x64-mingw32/2.4.0/commonmarker-0.17.6/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/commonmarker-0.17.6 for inspection.
Results logged to C:/Ruby24-x64/lib/ruby/gems/2.4.0/extensions/x64-mingw32/2.4.0/commonmarker-0.17.6/gem_make.out

C:\Users\Faris\salmanfaris>gem install github-pages
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions.  This could take a while...
ERROR:  Error installing github-pages:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/commonmarker-0.17.6/ext/commonmarker
C:/Ruby24-x64/bin/ruby.exe -r ./siteconf20171204-10152-13vmrk5.rb extconf.rb
checking for cmake... yes
CMake Error: CMake was unable to find a build program corresponding to "MSYS Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMake was unable to find a build program corresponding to "MSYS Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_AR was not found, please set to archive program.
-- Configuring incomplete, errors occurred!
make libcmark-gfm_static failed
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby24-x64/bin/$(RUBY_BASE_NAME)

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  C:/Ruby24-x64/lib/ruby/gems/2.4.0/extensions/x64-mingw32/2.4.0/commonmarker-0.17.6/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/commonmarker-0.17.6 for inspection.
Results logged to C:/Ruby24-x64/lib/ruby/gems/2.4.0/extensions/x64-mingw32/2.4.0/commonmarker-0.17.6/gem_make.out

windows 10 machine

@envygeeks
Copy link

I don't know why I'm being pinged here, but switch to Linux on Windows, it's better.

@vrubiolo
Copy link

Hi there, sorry for respawning the thread but I preferred to do so as I think it applies to my issue.

I am trying to install Jekyll locally as per the official instructions. It fails when trying to build/install commonmarker:

Installing commonmarker 0.17.9 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /home/vincent/.gem/ruby/gems/commonmarker-0.17.9/ext/commonmarker
/usr/bin/ruby -r ./siteconf20180425-8716-wb76yr.rb extconf.rb
Ignoring ffi-1.9.18 because its extensions are not built. Try: gem pristine ffi --version 1.9.18
Ignoring json-1.8.6 because its extensions are not built. Try: gem pristine json --version 1.8.6
Ignoring nokogiri-1.7.1 because its extensions are not built. Try: gem pristine nokogiri --version 1.7.1
mkmf.rb can't find header files for ruby at /usr/share/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /home/vincent/.gem/ruby/gems/commonmarker-0.17.9 for inspection.
Results logged to /home/vincent/.gem/ruby/extensions/x86_64-linux/2.4.0/commonmarker-0.17.9/gem_make.out
An error occurred while installing commonmarker (0.17.9), and Bundler cannot continue.
Make sure that gem install commonmarker -v '0.17.9' succeeds before bundling.
In Gemfile:
github-pages was resolved to 182, which depends on
jekyll-commonmark-ghpages was resolved to 0.1.5, which depends on
jekyll-commonmark was resolved to 1.2.0, which depends on
commonmarker

The issue is that ruby.h is present on my machine (this is Fedora 26), albeit in a different location: /usr/include/ruby.h

I have a workaround in that I just symlink /usr/share/include/ruby.h to that location but I am not sure what is the status of Jekyll support via Github on the various distros. Is that an expected error (I am a newbie for Ruby-related things)?

Thanks!

@stevenkissack
Copy link

I had the same above issue but it turned out I did need to install the ruby headers

sudo apt-get install ruby-all-dev

Link to solutions for other distros: StackOverflow Answer

Mine also needed zlib, so:

sudo apt-get install zlib1g-dev

@AlasdairGray
Copy link

On a Mac, make sure that you have the commandline tools installed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests