在CentOS 6上安装pg gem

时间:2014-04-25 20:03:15

标签: ruby-on-rails postgresql gem centos centos6

我试图在rails和postgres上使用ruby设置我的VPS(CentOS 6.4)。

我安装了ruby(2.1.0p0),rails(4.1.0)和postgresql(9.3.4)没有问题。

当我尝试创建新的rails应用程序(rails new new_app -d postgresql)时,它会在安装pg gem时停止。我已经查看了有关此错误的所有SO帖子,并尝试了我能找到的所有内容。最建议的是运行" yum install postgresql-devel"并且仍然没有工作。

您可以在下面找到ssh输出和mkmf.log。如果需要更多信息,请告诉我......


输出

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.

/home/deploy/.rvm/rubies/ruby-2.1.0/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/deploy/.rvm/rubies/ruby-2.1.0/bin/ruby
    --with-pg
    --without-pg
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib
/home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
    from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:1120:in `block in find_header'
    from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
    from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
    from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
    from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:321:in `open'
    from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
    from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
    from /home/deploy/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/mkmf.rb:1119:in `find_header'
    from extconf.rb:48:in `'

extconf failed, exit code 1


mkmf.log

"gcc -o conftest -I/home/deploy/.rvm/rubies/ruby-2.1.0/include/ruby-2.1.0/x86_64-linux -I/home/deploy/.rvm/rubies/ruby-2.1.0/include/ruby-2.1.0/ruby/backward -I/home/deploy/.rvm/rubies/ruby-2.1.0/include/ruby-2.1.0 -I. -I/usr/include     -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration  -fPIC conftest.c  -L. -L/home/deploy/.rvm/rubies/ruby-2.1.0/lib -Wl,-R/home/deploy/.rvm/rubies/ruby-2.1.0/lib -L/usr/lib64 -Wl,-R/usr/lib64 -L. -fstack-protector -rdynamic -Wl,-export-dynamic     -Wl,-rpath,'/../lib' -Wl,-R -Wl,'/../lib' -L'/../lib' -lruby  -lpthread -lrt -ldl -lcrypt -lm   -lc"
gcc: error trying to exec 'as': execvp: Permission denied
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

6 个答案:

答案 0 :(得分:7)

<强>之前:

对于Centos 6 :使用此guide右键安装Postgres 9. *。

<强>后:

yum install postgresql-libs postgresql-devel

有用的指示:

How to setup RoR with Postgres

答案 1 :(得分:6)

由于您没有使用CentOS 6附带的过时PostgreSQL版本(PostgreSQL 8.4),您需要安装与您的版本匹配的-devel软件包(PostgreSQL 9.X)。

最简单的方法是使用official PostgreSQL yum repository

由于最新版本是9.5并且它与所有9.X版本兼容,我将编写该版本的说明。将来您可以参考official instructions获取更新的命令。

yum install http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.5-2.noarch.rpm
yum install postgresql95-devel

然后使用-with-pg-config选项安装gem:

gem install pg -- --with-pg-config=/usr/pgsql-9.5/bin/pg_config

答案 2 :(得分:5)

这对我来说更容易:

 codMsgBox "here is your numbers" & " " & tmp1 & " " & tmp2 & " " & tmp3
End Sube 

答案 3 :(得分:0)

尝试这样的事情;

before "bundle:install" do
  run "ls -l #{fetch(:latest_release)}/Gemfile"
  #run "bundle config  --local --gemfile=#{fetch(:latest_release)}/Gemfile build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config"
  run "cd #{fetch(:latest_release)} && bundle config build.pg --with-pg-config=/usr/pgsql-9.3/bin/pg_config"
end

答案 4 :(得分:0)

您可以尝试使用postres pg_config文件路径选项安装pg gem:

gem install pg -- --with-pg-config=/usr/pgsql-9.2/bin/pg_config

请根据您的系统更新路径

此致

答案 5 :(得分:0)

我的mac上遇到了这个问题,这是一个bash / RVM问题。我不得不把它添加到我的bash: [[-s“$ HOME / .rvm / scripts / rvm”]]&amp;&amp;源“$ HOME / .rvm / scripts / rvm”。鉴于它正在查找配置文件,我会调查一下。