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

5

6

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!

Sabinesabino answered 4/3, 2013 at 18:32 Comment(0)
A
5

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

Arnaldo answered 4/3, 2013 at 19:0 Comment(2)
That was it - thanks @devneck! Unfortunately, I think I've installed a few gems with the use of sudo so that may cause me some pain down the road, but I'll make sure to keep this in mind.Sabinesabino
Also, there was an issue when I tried to start the thin web server, but it was fixed by simply adding thin to the Gemfile.Sabinesabino
Y
5

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

Yemen answered 6/8, 2013 at 19:1 Comment(1)
That was it! Amazon LinuxBurgin
E
3

I have same problem in Ubuntu 12.04 . Solved by:

sudo apt-get install build-essential
sudo apt-get install curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev
Eagle answered 7/8, 2013 at 9:43 Comment(3)
I had actually tried these before trying to install thin, but I would still get the error mentioned above. The trick for me was to install the gem without prefacing the command with 'sudo', but I think the steps you've shown are still important in the process.Sabinesabino
On ubuntu 14.04, I just had to do: 'sudo apt-get install build-essential' followed by 'sudo gem install thin'Gnat
For ubuntu 14.04 I did sudo apt-get install libpq-devEagle
C
2

Try below command it will helps to resolve the problem

sudo gem install thin -- --with-cflags=\"-O2 -pipe -march=native -w\"
Cordeliacordelie answered 8/4, 2015 at 14:39 Comment(0)
C
1

This did it for me:

sudo apt-get install ruby-dev

Cheers

Compressibility answered 19/6, 2015 at 12:11 Comment(1)
I had to do sudo apt-get install ruby-dev build-essentials on a new install of Ubuntu 16.04Tinner

© 2022 - 2024 — McMap. All rights reserved.