【问题标题】:pg gem installation is giving error in Redhatpg gem 安装在 Redhat 中出现错误
【发布时间】:2020-01-24 18:44:37
【问题描述】:

我正在执行gem install pg 以安装 pg 并随后在 Redhat AWS 机器上执行厨师脚本。我收到以下错误:

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

current directory: /opt/chef/embedded/lib/ruby/gems/2.5.0/gems/pg-1.1.4/ext/opt/chef/embedded/bin/ruby -r ./siteconf20190924-20230-k0ngu5.rb extconf.rb
checking for pg_config... yes
Using config values from /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
       --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=/opt/chef/embedded/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=${pg-dir}/include
       --with-pg-lib
       --without-pg-lib=${pg-dir}/lib

/opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:467:in `try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first.
       from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:601:in `try_cpp'
       from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:1162:in `block in find_header'
       from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:959:in `block in checking_for'
       from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:350:in `block (2 levels) in postpone'
       from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:320:in `open'
       from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:350:in `block in postpone'
       from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:320:in `open'
       from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:346:in `postpone'
       from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:958:in `checking_for'
       from /opt/chef/embedded/lib/ruby/2.5.0/mkmf.rb:1161:in `find_header'
       from extconf.rb:54:in `<main>'

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

/opt/chef/embedded/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0/pg-1.1.4/mkmf.log

extconf failed, exit code 1

我正在尝试使用 root 用户。我也使用 yum 安装了 postgresql-devel 并尝试在 libpq-fe.h 所在的位置提供 --with-pg-include(在其他一些帖子中建议)但无法解决问题。

【问题讨论】:

    标签: ruby postgresql chef-infra pg


    【解决方案1】:

    您首先需要为您的 postgres 服务器安装构建工具(即 C 编译器和相关工具)以及开发头文件,以便能够编译 gem。

    对于 RedHat,您应该能够获得所有必需的工具

    yum install autoconf bison flex gcc gcc-c++ gettext kernel-devel make m4 ncurses-devel patch
    yum install postgresql-devel
    

    使用 Chef 14,您可以使用内置的 build_essential resource 来安装所需的编译器包。在旧版本上,您可以使用build-essential cookbook

    【讨论】:

    • 谢谢,实际上我的情况下缺少 gcc
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-10-04
    • 2014-01-16
    • 2012-12-15
    • 1970-01-01
    • 2014-08-20
    • 2011-08-11
    • 2013-05-21
    相关资源
    最近更新 更多