Unable to install Nokogiri - ruby-on-rails

When I run sudo gem install nokogiri on Ubuntu 12.1, I'm returned with this. What's wrong and how do I fix it?
jason#jason:~/ror/clss$ sudo gem install nokogiri
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
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:5:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/nokogiri-1.5.5 for
inspection. Results logged to /var/lib/gems/1.9.1/gems/nokogiri-1.5.5/ext/nokogiri
/gem_make.out

Try to install the "libxslt-dev" and "libxml2-dev" packages:
sudo apt-get install libxslt-dev libxml2-dev
The instructions are on http://nokogiri.org/tutorials/installing_nokogiri.html
Update:
You need sudo aptitude install ruby1.9.1-dev.
Source: "Rails Tutorial: nokogiri-1.5.2 error on bundle install".

Related

ERROR: Failed to buld gem native extension?

I am installing riemann monitoring tool on my PC. I run the following command from terminal:
Command:
sudo gem install riemann-tools
I get the following error:
ERROR: Error installing riemann-tools:
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:1:in `<main>'
A similar error comes when installing riemann-dash but riemann-client get installed successfully.
I am using Ububtu 12.10.
I read online about such errors and it had something with ruby version, but I am not able to figure out the reason for this.
Any help is appreciated.
this solved it for me:
For Debian/Ubuntu
apt-get install ruby-dev zlib1g-dev
For RedHat/CentOS/Fedora:
yum install ruby-devel zlib-devel

Cannot install mysql2 gem on Debian

Trying to get the gem mysql2 to install and I just cannot get it to work. Before trying to install I installed the following
sudo apt-get install mysql-client libmysqlclient-dev
Then I go to install mysql2 and get
sudo gem install mysql2
Here is the error I am getting. Thanks
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
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>'
you need ruby-dev
sudo aptitude install ruby1.9.1-dev
should fix it.

Rails 3, error installing pg gem

Tried to install pg gem I got the next error:
alex#ubuntu:~/RubymineProjects/Tiger Skills$ gem install pg
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions into the /var/lib/gems/1.9.1 directory.
alex#ubuntu:~/RubymineProjects/Tiger Skills$ sudo gem install pg
Building native extensions. This could take a while...
ERROR: Error installing pg:
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>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/pg-0.15.1 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/pg-0.15.1/ext/gem_make.out
gem_make.out file:
/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>'
Already tryed to solve using
$ sudo apt-get install postgresql-client libpq5 libpq-dev
then:
$ sudo gem install pg
That is because you have not set the write permission to the directory,try:
chmod +777 /var/lib/gems/1.9.1
You need to install the -dev part of the Ruby package. Something like:
sudo apt-get install ruby1.9-dev
should give you the parts of Ruby necessary to compile binary extensions.
Good luck!
This help me:
sudo apt-get install rails
I got almost the same problem.
I use this to solve it.
$rvmsudo gem install pg

Rails installation failed on Ubuntu with "cannot load such file -- mkmf"

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
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 :)
For ubuntu 13.04, this is what worked for me:
sudo apt-get install ruby-dev
try
rvm all do gem install nokogiri

Why do I get an error installing the JSON gem in Ubuntu?

Using Ubuntu, when I run "bundle install" to set up my Rails environment, it throws an error during the JSON gem installation:
Installing json (1.7.3) with native extensions
Gem::Installer::ExtensionBuildError: 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:1:in `<main>'
Gem files will remain installed in /home/danny/.bundler/tmp/2040/gems/json-1.7.3 for inspection.
Results logged to /home/danny/.bundler/tmp/2040/gems/json-1.7.3/ext/json/ext/parser/gem_make.out
An error occured while installing json (1.7.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.7.3'` succeeds before bundling.
When I try installing only the JSON 1.7.3 gem it also gives me an error:
Building native extensions. This could take a while...
ERROR: Error installing json:
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:1:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/json-1.7.3 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/json-1.7.3/ext/json/ext/parser/gem_make.out
I've installed RVM and am running Ruby 1.9.3; Why can't it install the JSON gem?
Installing the ruby1.9.1-dev package should fix this for you:
sudo apt-get install ruby1.9.1-dev

Resources