Rails 3, error installing pg gem - ruby-on-rails

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

Related

cannot load such file -- mkmf (LoadError)

Using rbenv, runnng bundle install, and getting an error installing Json 1.8.1.
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>'
Tried installing ruby-dev via apt (not sure that will help anyway, as ruby was installed via rbenv)
stuff that may help?
$ which gem
/home/ubuntu/.rbenv/shims/gem
$ which ruby
/home/ubuntu/.rbenv/shims/ruby
$ locate mkmf
/home/ubuntu/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/mkmf.rb
/home/ubuntu/.rbenv/versions/1.9.3-p484/share/ri/1.9.1/system/Object/mkmf-i.ri
/usr/local/rvm/gems/ruby-2.2.1/extensions/x86_64-linux/2.2.0/nokogiri-1.6.6.2/mkmf.log
/usr/local/rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/mkmf.rb
Based on your locate command, you have mkmf in rvm and in ubuntu's home diretory, but not on the system, and you're explicitly using the system's ruby (and not rbenv or rvm) to run the extconf.rb. Either run a ruby from one of the environments you have mkmf in, or install the ruby-dev package on the system.

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.

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