Gem::Ext::BuildError: 错误: 无法构建本地扩展宝石。- CentOS 6.5

4
我正在尝试在CentOS 6.5上运行Nginx 1.4.7上的Ruby版本2.0.0-p353。所有安装步骤都符合预期,但当我运行代码bundle install时,出现以下错误:

Gem::Ext::BuildError: 错误:无法构建本地扩展宝石。

/usr/local/rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb 
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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=/usr/local/rvm/rubies/ruby-2.0.0-p353/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}/

extconf failed, exit code 1

Gem files will remain installed in /root/.rvm/gems/ruby-2.0.0-p353@rails4/gems/pg-0.17.1 for inspection.
Results logged to /root/.rvm/gems/ruby-2.0.0-p353@rails4/extensions/x86_64-linux/2.0.0/pg-0.17.1/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.

我找不到提到的mkmf.log文件。

你已经安装了 PostgreSQL 吗? - Roman Kiselenko
1个回答

8
checking for libpq-fe.h... no

你需要安装Postgresql开发库。
尝试执行以下命令:
yum install postgresql-devel

或者与您的操作系统相关的任何内容。


好的,我尝试了这个方法,以为它解决了问题,但实际上并没有。仍然出现完全相同的错误。当我执行 yum install postgresql-devel 命令时,实际上得到的响应是 Package postgresql93-devel-9.3.4-1PGDG.rhel6.x86_64 already installed and latest version - eComEvo
8
尝试:export PATH=/usr/pgsql-9.3/bin:$PATH bundle install - SreekanthGS
可以确认@SreekanthGS的解决方案完美地运行。在我的$PATH前面加上/usr/bin/pgsql-9.3/bin:并重新启动会话,使得gem安装顺利进行! - Pierce
我确认。我需要这最后一步。 - hachpai

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接