49

I have this problem while installing Rails on Ubuntu 11:

root@salah:/home/salah/rubygems-1.8.15# sudo gem install mysql

Fetching: mysql-2.8.1.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
    ERROR: Failed to build gem native extension.

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


Gem files will remain installed in /usr/lib/ruby/gems/1.9.1/gems/mysql-2.8.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.9.1/gems/mysql-2.8.1/ext/mysql_api/gem_make.out
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
user1720731
  • 491
  • 1
  • 4
  • 3
  • 1
    You have a problem to install the mysql gem, not Rails right? Anyway, I'm not sure the mysql gem is still maintained ... the `mysql2` gem is now the standard – Anthony Alberto Oct 04 '12 at 16:54
  • 1
    Possible duplicate of [\`require': no such file to load -- mkmf (LoadError)](http://stackoverflow.com/questions/7645918/require-no-such-file-to-load-mkmf-loaderror) – kenorb Nov 01 '15 at 15:53

3 Answers3

75

mkmf is part of the ruby-dev package if I'm not mistaken. Try:

sudo aptitude install ruby1.9.1-dev

Of course you may be better off installing ruby through RVM :)

Peter Duijnstee
  • 3,759
  • 2
  • 20
  • 30
66

For ubuntu 13.04, this is what worked for me:

sudo apt-get install ruby-dev
edelans
  • 8,479
  • 4
  • 36
  • 45
  • "sudo apt-get install ruby-dev" will not work if you had ubuntu 12.04 with ruby 1.9.1 and then upgraded to 14.04. First of all you need to delete ruby as "sudo apt-get remove ruby", then install as "sudo apt-get install ruby1.9.3", and only after that you can install ruby-dev, otherwise you will have dependency issue. – Viktor Jan 22 '15 at 17:08
-1

try rvm all do gem install nokogiri

Darren Cato
  • 1,382
  • 16
  • 22