Bundler声称它正在安装pg,但后来抱怨说它不能安装它(RHEL7)

问题描述:

你知道bundler会声称为什么要安装pg gem,然后抱怨它不能编译它吗?它表明gem没有并行安装,但是继续尝试安装pg,不会产生错误,安装rmagick,然后为p*生错误。Bundler声称它正在安装pg,但后来抱怨说它不能安装它(RHEL7)

当我在Gemfile中查看rmagick之前列出的pg ...非常困惑。

 
Rubygems 2.0.14 is not threadsafe, so your gems will be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem installation. 
Using rake 11.3.0 
Using i18n 0.7.0 
Using json 1.8.3 
Using minitest 5.9.1 
Using thread_safe 0.3.5 
Using builder 3.2.2 
Using erubis 2.7.0 
Using mini_portile2 2.1.0 
Using pkg-config 1.1.7 
Using rack 1.6.4 
Using mime-types-data 3.2016.0521 
Using arel 6.0.3 
Using addressable 2.4.0 
Using bundler 1.13.2 
Using coderay 1.1.1 
Using concurrent-ruby 1.0.2 
Using htmlentities 4.3.1 
Using thor 0.19.1 
Using mimemagic 0.3.2 
Using net-ldap 0.12.1 
Installing pg 0.18.4 with native extensions 
Using ruby-openid 2.3.0 
Using rbpdf-font 1.19.0 
Using redcarpet 3.3.4 
Using request_store 1.0.5 
Installing rmagick 2.16.0 with native extensions 
Using tzinfo 1.2.2 
Installing nokogiri 1.6.8 with native extensions 
Using rack-test 0.6.3 
Using mime-types 3.1 
Using css_parser 1.3.7 
Using sprockets 3.7.0 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. 

    /usr/bin/ruby extconf.rb 
checking for pg_config... yes 
Using config values from /usr/bin/pg_config 
*** 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}/lib64 
    --with-make-prog 
    --without-make-prog 
    --srcdir=. 
    --curdir 
    --ruby=/usr/bin/ruby 
    --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}/ 
/usr/share/ruby/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError) 
You have to install development tools first. 
    from /usr/share/ruby/mkmf.rb:519:in `try_link0' 
    from /usr/share/ruby/mkmf.rb:534:in `try_link' 
    from extconf.rb:36:in `' 


Gem files will remain installed in /tmp/.gem/ruby/gems/pg-0.18.4 for inspection. 
Results logged to /tmp/.gem/ruby/gems/pg-0.18.4/ext/gem_make.out 

An error occurred while installing pg (0.18.4), and Bundler cannot continue. 
Make sure that `gem install pg -v '0.18.4'` succeeds before bundling. 
+1

说它正在安装它 - 它告诉你,这就是今天要尝试安装的东西...并不是它已经成功安装它。为了解决这个问题,谷歌这个错误:'extconf.rb失败'和“pg gem”(问题是这部分:“你必须先安装开发工具。”) –

+0

所以你的意思是所有的行在“使用本机扩展安装pg 0.18.4”之后与创建pg gem有关?为什么必须安装rmagick来安装pg gem?它具体表明它不是并行安装东西。 – Angelo

+0

它没有...正如我所说的,'Installing '这个词并不意味着“我刚刚安装了叫做'gemname'的宝石” - 他们只是说“在这个捆绑过程中,我会安装宝石叫做'gemname'“... ... bundler通过你的Gemfile查找需要安装的所有gem,不管它们是自己列出还是依赖于另一个......并列出所有需要安装的安装...''pg'和'rmagick'之间可能没有任何连接,除非还没有安装。 –

您可能没有安装PostgreSQL。它也发生在我的macOS上。我只是做了brew install postgresql并再次运行bundle。如果你在任何其他操作系统上,你需要相应地安装PostgreSQL。
这将做的是安装宝石所需的所有缺少的库。

很可能你没有在你的机器上安装postgresql软件。 这就是为什么当你试图安装gem时,它找不到postgresql软件的executable.Hence打包程序无法安装gem。 在机器上安装PostgreSQL

sudo apt-get install postgresql postgresql-contrib #If you are on linux(ubuntu). 

brew install postgresql #If you are on mac 

希望你有你的答案。享受