Cannot install mysql2 gem on Debian - ruby-on-rails

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.

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

Fail to deploy rails app on ubuntu 14.04

I'm trying to deploy my Rails 4 app on Azure VM running Ubuntu 14.04.
Here's a logfile, atomic fails to install. ruby-v gives me ruby 2.0.0p451
Any ideas how to fix that?
azureuser#my-url:~$ sudo gem install atomic
Building native extensions. This could take a while...
ERROR: Error installing atomic:
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:13:in `<main>'
Gem files will remain installed in /var/lib/gems/1.9.1/gems/atomic-1.1.15 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/atomic-1.1.15/ext/gem_make.out
azureuser#my-url:~$ ruby -v
ruby 2.0.0p451 (2014-02-24 revision 45167) [x86_64-linux]
Your gems are using ruby1.9.1 and you are missing dev files.
So install that using this command
sudo apt-get install ruby1.9.1-dev
If you are not sure about your ruby version you can use this command
sudo apt-get install ruby-dev
Make sure you also have the build-essential package installed. You can check using dpkg -l | grep build-essential or simply run sudo apt-get install build-essential.
Personally I tried lots of things before realizing I was missing the above mentioned package.

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

Unable to install Nokogiri

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".

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

Resources