0

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
Alex Klimashevsky
  • 2,457
  • 3
  • 26
  • 58

4 Answers4

1

That is because you have not set the write permission to the directory,try:

   chmod +777 /var/lib/gems/1.9.1
Denzil
  • 326
  • 3
  • 15
0

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!

Michael Granger
  • 1,358
  • 9
  • 14
0

This help me:

sudo apt-get install rails 
Alex Klimashevsky
  • 2,457
  • 3
  • 26
  • 58
0

I got almost the same problem.
I use this to solve it.

$rvmsudo gem install pg
finkfink
  • 175
  • 3
  • 12