问题
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!
回答1:
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
回答2:
I had a similar error to this outside of rvm, I found that i needed to install ruby-devel
回答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
回答4:
Try below command it will helps to resolve the problem
sudo gem install thin -- --with-cflags=\"-O2 -pipe -march=native -w\"
回答5:
This did it for me:
sudo apt-get install ruby-dev
Cheers
来源:https://stackoverflow.com/questions/15208525/error-installing-gem-failed-to-build-gem-native-extensions-cannot-load-such-f