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
4

4 回答 4

1

那是因为你没有设置目录的写权限,试试:

   chmod +777 /var/lib/gems/1.9.1
于 2013-05-25T20:17:33.267 回答
0

我遇到了几乎同样的问题。
我用这个来解决它。

$rvmsudo gem install pg
于 2014-03-13T03:30:03.663 回答
0

您需要安装 Ruby 包的 -dev 部分。就像是:

sudo apt-get install ruby1.9-dev

应该为您提供编译二进制扩展所需的 Ruby 部分。

祝你好运!

于 2013-05-26T18:57:31.607 回答
0

这对我有帮助:

sudo apt-get install rails 
于 2013-05-26T18:57:54.947 回答