Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error installing gem failed to build gem native extensions -- cannot load such file -- mkmf

RoR is nice, but sometimes makes me want to bang my head against the wall (and it's probably my fault anyway). I'm simply trying to install the Thin web-client gem, and when I run sudo gem install thin, I get the following error (it requires the installation of the eventmachine gem first):

    sudo gem install thin
    Fetching: eventmachine-1.0.1.gem (100%)
    Building native extensions.  This could take a while...
    ERROR:  Error installing thin:
            ERROR: Failed to build gem native extension.

            /usr/bin/ruby1.9.1 extconf.rb
            /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
            from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
            from extconf.rb:2:in `<main>'

I've searched for the "cannot load such file -- mkmf" error, but most issues seem to be surrounding the fact that it was available in 1.8-dev but not 1.8, but as I'm running 1.9.3 I figured I had mkmf - which I verified with locate mkmf:

    /home/ubuntu/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/mkmf.rb

The directory that mkmf is located in is obviously not under the /usr/lib/ruby/... directory - I'm not sure if this is my problem or not, but it maybe enough to jumpstart one of you experts out there as to what's going on and what the solution could be.

Also, I've used RVM to install ruby 1.9.3 rather than just a gem install...

Thanks in advance!

like image 610
MandM Avatar asked Mar 04 '13 18:03

MandM


2 Answers

if you're using RVM, you shouldn't ever be using 'sudo'. Using sudo calls libs and such out of the rvm path. Try just a flat

gem install thin

and see if that helps.

~Kevin

like image 110
Devneck Avatar answered Nov 14 '22 21:11

Devneck


I had a similar error to this outside of rvm, I found that i needed to install ruby-devel

like image 36
Xarses Avatar answered Nov 14 '22 22:11

Xarses