ruby-on-rails - Gem::Ext::BuildError:错误:无法构建 gem native 扩展。 - 中央操作系统 6.5

标签 ruby-on-rails ruby postgresql centos

我正在尝试让 Ruby 版本 2.0.0-p353 在 CentOS 6.5 上的 Nginx 1.4.7 上运行。一切都按预期安装,但是当我开始运行 bundle install 时,出现以下错误:

Gem::Ext::BuildError:错误:无法构建 gem native 扩展。

/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 文件。

最佳答案

checking for libpq-fe.h... no

您需要 Postgresql 开发库。

尝试:

yum install postgresql-devel

或任何特定于您的操作系统的内容。

关于ruby-on-rails - Gem::Ext::BuildError:错误:无法构建 gem native 扩展。 - 中央操作系统 6.5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23283999/

相关文章:

ruby-on-rails - 如何强制 Jruby 使用内置的 Ruby 1.9 而不是默认的 Ruby 1.8?

PHP 通过单击对表格进行排序,然后再单击一次进行反向排序

ruby-on-rails - 如何使用 gem 移动性按区域设置过滤记录?

sql - 当 select 语句没有返回记录时,函数中的变量会得到什么?

python - 使用 session.query 读取 SQLAlchemy 中未提交的数据

ruby-on-rails - 从 Rails 4.2.1 升级

ruby-on-rails - 带有嵌套资源 : update belongs_to association when creating new has_many 的 Rails 嵌套表单

ruby-on-rails - 我应该为模型编写什么样的 RSpec 测试?

ruby - 在 after_commit 钩子(Hook)中缓存数据时确保一致性

html - Bootstrap 将搜索表单放在右边