linux - PG + extconf 失败,在 Linux 中退出代码 1

标签 linux postgresql centos rubygems

我在 Linux (CentOS) 系统中安装 PG 时遇到错误。

gem install pg

然后我得到以下错误

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

    current directory: /usr/local/rvm/gems/ruby-2.3.0/gems/pg-0.18.4/ext
/usr/local/rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160831-5454-1endyls.rb extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/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.3.0/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
    --without-pg-lib=${pg-dir}/lib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/pg-0.18.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /usr/local/rvm/gems/ruby-2.3.0/gems/pg-0.18.4 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/pg-0.18.4/gem_make.out

为了解决这个问题,我尝试了很多东西并安装了所需的软件包,但仍然遇到同样的错误。你可以看到我的 postgres 日志*

运行后

yum list postgres*

Loaded plugins: priorities, update-motd, upgrade-helper
24 packages excluded due to repository priority protections
Installed Packages
postgresql92.x86_64                                                                   9.2.15-1.57.amzn1                                                        @amzn-main  
postgresql92-contrib.x86_64                                                           9.2.15-1.57.amzn1                                                        @amzn-main  
postgresql92-devel.x86_64                                                             9.2.15-1.57.amzn1                                                        @amzn-main  
postgresql92-libs.x86_64                                                              9.2.15-1.57.amzn1                                                        @amzn-main  
postgresql92-server.x86_64                                                            9.2.15-1.57.amzn1                                                        @amzn-main  
postgresql92-server-compat.x86_64                                                     9.2.15-1.57.amzn1                                                        @amzn-main  
postgresql93.x86_64                                                                   9.3.11-1.61.amzn1                                                        @amzn-main  
postgresql93-contrib.x86_64                                                           9.3.11-1.61.amzn1                                                        @amzn-main  
postgresql93-devel.x86_64                                                             9.3.11-1.61.amzn1                                                        @amzn-main  
postgresql93-libs.x86_64                                                              9.3.11-1.61.amzn1                                                        @amzn-main  
postgresql93-server.x86_64                                                            9.3.11-1.61.amzn1                                                        @amzn-main  
postgresql94.x86_64                                                                   9.4.6-1.66.amzn1                                                         @amzn-main  
postgresql94-libs.x86_64                                                              9.4.6-1.66.amzn1                                                         @amzn-main  
Available Packages
postgresql-jdbc.noarch                                                                8.4.701-8.11.amzn1                                                       amzn-main   
postgresql-jdbc-javadoc.noarch                                                        9.4.1208-1.rhel6                                                         pgdg92      
postgresql-odbc.x86_64                                                                08.04.0200-1.6.amzn1                                                     amzn-main   
postgresql8.x86_64                                                                    8.4.20-5.52.amzn1                                                        amzn-updates
postgresql8-contrib.x86_64                                                            8.4.20-5.52.amzn1                                                        amzn-updates
postgresql8-devel.x86_64                                                              8.4.20-5.52.amzn1                                                        amzn-updates
postgresql8-docs.x86_64                                                               8.4.20-5.52.amzn1                                                        amzn-updates
postgresql8-libs.i686                                                                 8.4.20-5.52.amzn1                                                        amzn-updates
postgresql8-libs.x86_64                                                               8.4.20-5.52.amzn1                                                        amzn-updates
postgresql8-plperl.x86_64                                                             8.4.20-5.52.amzn1                                                        amzn-updates
postgresql8-plpython.x86_64                                                           8.4.20-5.52.amzn1                                                        amzn-updates
postgresql8-pltcl.x86_64                                                              8.4.20-5.52.amzn1                                                        amzn-updates
postgresql8-server.x86_64                                                             8.4.20-5.52.amzn1                                                        amzn-updates
postgresql8-test.x86_64                                                               8.4.20-5.52.amzn1                                                        amzn-updates
postgresql92-debuginfo.x86_64                                                         9.2.18-1PGDG.rhel6                                                       pgdg92      
postgresql92-docs.x86_64                                                              9.2.15-1.57.amzn1                                                        amzn-main   
postgresql92-libs.i686                                                                9.2.15-1.57.amzn1                                                        amzn-main   
postgresql92-odbc.x86_64                                                              09.05.0400-1PGDG.rhel6                                                   pgdg92      
postgresql92-plperl.x86_64                                                            9.2.15-1.57.amzn1                                                        amzn-main   
postgresql92-plpython.x86_64                                                          9.2.18-1PGDG.rhel6                                                       pgdg92      
postgresql92-plpython26.x86_64                                                        9.2.15-1.57.amzn1                                                        amzn-main   
postgresql92-plpython27.x86_64                                                        9.2.15-1.57.amzn1                                                        amzn-main   
postgresql92-pltcl.x86_64                                                             9.2.15-1.57.amzn1                                                        amzn-main   
postgresql92-python.x86_64                                                            4.2-1PGDG.rhel6                                                          pgdg92      
postgresql92-python-debuginfo.x86_64                                                  4.2-1PGDG.rhel6                                                          pgdg92      
postgresql92-tcl.x86_64                                                               2.1.1-1.rhel6                                                            pgdg92      
postgresql92-tcl-debuginfo.x86_64                                                     2.1.1-1.rhel6                                                            pgdg92      
postgresql92-test.x86_64                                                              9.2.15-1.57.amzn1                                                        amzn-main   
postgresql93-docs.x86_64                                                              9.3.11-1.61.amzn1                                                        amzn-main   
postgresql93-libs.i686                                                                9.3.11-1.61.amzn1                                                        amzn-main   
postgresql93-plperl.x86_64                                                            9.3.11-1.61.amzn1                                                        amzn-main   
postgresql93-plpython26.x86_64                                                        9.3.11-1.61.amzn1                                                        amzn-main   
postgresql93-plpython27.x86_64                                                        9.3.11-1.61.amzn1                                                        amzn-main   
postgresql93-pltcl.x86_64                                                             9.3.11-1.61.amzn1                                                        amzn-main   
postgresql93-test.x86_64                                                              9.3.11-1.61.amzn1                                                        amzn-main   
postgresql94-contrib.x86_64                                                           9.4.6-1.66.amzn1                                                         amzn-main   
postgresql94-devel.x86_64                                                             9.4.6-1.66.amzn1                                                         amzn-main   
postgresql94-docs.x86_64                                                              9.4.6-1.66.amzn1                                                         amzn-main   
postgresql94-libs.i686                                                                9.4.6-1.66.amzn1                                                         amzn-main   
postgresql94-plperl.x86_64                                                            9.4.6-1.66.amzn1                                                         amzn-main   
postgresql94-plpython26.x86_64                                                        9.4.6-1.66.amzn1                                                         amzn-main   
postgresql94-plpython27.x86_64                                                        9.4.6-1.66.amzn1                                                         amzn-main   
postgresql94-server.x86_64                                                            9.4.6-1.66.amzn1                                                         amzn-main   
postgresql94-test.x86_64                                                              9.4.6-1.66.amzn1                                                         amzn-main   
postgresql_autodoc.noarch                                                             1.41-1.rhel6                                                             pgdg92      

无法安装 pg。请帮助我。

我安装了

yum install postgresql92-server
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main/latest                                                                                                                                    | 2.1 kB     00:00     
amzn-updates/latest                                                                                                                                 | 2.3 kB     00:00     
24 packages excluded due to repository priority protections
Package postgresql92-server-9.2.15-1.57.amzn1.x86_64 already installed and latest version
Nothing to do

最佳答案

看来您必须安装 postgres 头文件和库。 因为你的系统是 RHEL 试试这个。

yum install postgresql-devel

如果你使用的是 postgres 9.4,那么,

yum install postgresql94-devel

然后重新运行 gem install pg 'version'

关于linux - PG + extconf 失败,在 Linux 中退出代码 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39251264/

相关文章:

linux - tomcat启动脚本错误

php - 为什么我的 ../在我的包含中不起作用

linux - 安装 glibc 2.7 后出现段错误

php - xDebug 没有在断点处停止

c# - 为什么 FileSystemWatcher 在监视 Windows 卷的 Linux 容器中不起作用

linux - Pidof 找不到进程

sql - 如何优化显示 2 个相邻行且值时间戳已关闭的 SQL 查询?

php - 新服务器 : Troubleshooting PostgreSQL Syntax Error

linux - 从 Linux/Windows 编译 Mac

postgresql - Postgres 角色和用户 - 表的权限被拒绝