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!

MandM
  • 3,293
  • 4
  • 34
  • 56

5 Answers5

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

Martlark
  • 14,208
  • 13
  • 83
  • 99
Devneck
  • 144
  • 1
  • 1
  • 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. – MandM Mar 04 '13 at 19:01
  • 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. – MandM Mar 04 '13 at 19:10
5

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

Xarses
  • 315
  • 3
  • 8
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
toro2k
  • 19,020
  • 7
  • 64
  • 71
  • 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. – MandM Aug 21 '13 at 14:40
  • 1
    On ubuntu 14.04, I just had to do: 'sudo apt-get install build-essential' followed by 'sudo gem install thin' – genegc Jul 03 '14 at 17:32
  • For ubuntu 14.04 I did sudo apt-get install libpq-dev – Deepak Shinde Dec 26 '14 at 09:16
2

Try below command it will helps to resolve the problem

sudo gem install thin -- --with-cflags=\"-O2 -pipe -march=native -w\"
Getz
  • 3,983
  • 6
  • 35
  • 52
1

This did it for me:

sudo apt-get install ruby-dev

Cheers

Vingtoft
  • 13,368
  • 23
  • 86
  • 135
  • I had to do `sudo apt-get install ruby-dev build-essentials` on a new install of Ubuntu 16.04 – Phrogz Oct 02 '17 at 15:43