ruby-on-rails - gem install pg for ruby​​ on rails,错误消息 : lack of necessary libraries and/or headers

标签 ruby-on-rails ruby postgresql ubuntu rubygems

我是 ruby​​ 新手,在尝试 gem install pg 时遇到并得到这个问题

Building native extensions with: '--with-pg-lib=/usr/lib'
This could take a while...
ERROR:  Error installing pg:
ERROR: Failed to build gem native extension.
checking for pg_config... yes
Using config values from /home/linuxbrew/.linuxbrew/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/chensiyuan/.rbenv/versions/2.5.1/bin/$(RUBY_BASE_NAME)
--with-pg
--without-pg
--enable-windows-cross
--disable-windows-cross
--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=${pg-dir}/lib

我检查了日志文件,它显示如下
gcc: error: unrecognized command line option '-Wmisleading-indentation'
gcc: error: unrecognized command line option '-Wimplicit-fallthrough=0'
gcc: error: unrecognized command line option '-Wduplicated-cond'
gcc: error: unrecognized command line option '-Wrestrict'
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: int main(int argc, char **argv)
4: {
5:   return 0;
6: }
/* end */

我已经安装了postgresql
sudo apt install linuxbrew-wrappersudo apt-get install build-essentialsudo apt-get install libpq-devbrew install postgresql
这就是我在搜索其他笔记后为这个问题所做的。有人可以帮我吗?我已经检查了所有可能的重复项,上述命令来自这些答案。但是,我的 ubuntu 仍然提示同样的问题。

最佳答案

如果您的 brew install postgresql已安装成功安装,然后尝试bundle install再次在 ruby​​ 应用程序中。

关于ruby-on-rails - gem install pg for ruby​​ on rails,错误消息 : lack of necessary libraries and/or headers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52900999/

相关文章:

ruby-on-rails - Rack Gem::LoadError 即使我使用的是 Bundler

ruby-on-rails - RSPEC 测试名称错误 - 未定义的局部变量或方法

ruby - Resque 任务总是失败 - 未初始化的作业常量?

sql - 根据第三列动态选择两列之一

ruby-on-rails - Rails 迁移 : tried to change the type of column from string to integer

ruby-on-rails - 回形针更新后突然抛出一个奇怪的错误

ruby-on-rails - 建立所需的连接

mysql - 使用查询添加行值

PostgreSQL:一个数据库到多个用户

ruby-on-rails - Backbone.js 和 Rails 3 如何构建具有身份验证的应用程序?