【问题标题】:gem install pg -v '0.17.1' not working for some reasongem install pg -v '0.17.1' 由于某种原因无法正常工作
【发布时间】:2018-06-15 10:07:17
【问题描述】:

我正在尝试通过 AWS EC2 Linux 服务器中的 rails 应用程序“捆绑”。我收到“pg”gem 的这个错误。有人可以帮忙吗?找不到解决办法。

此 gem 'pg' 的版本为 0.17.1。

Ruby 版本是 ruby​​ 2.3.1p112(2016-04-26 修订版 54768)[x86_64-linux]

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

    current directory: /home/ec2-user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pg-0.21.0/ext
/home/ec2-user/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20180105-17661-1wdsn6j.rb 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:
    --something something something

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

  /home/ec2-user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-0.21.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/ec2-user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/pg-0.21.0 for inspection.
Results logged to /home/ec2-user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/pg-0.21.0/gem_make.out

【问题讨论】:

    标签: ruby-on-rails ruby postgresql amazon-ec2 postgresql-9.1


    【解决方案1】:

    当我在centosubuntu 上安装gem 'pg' 时,我遇到了和你一样的问题。

    对于centos,你可以这样做:

    yum install postgresql-libs
    yum install postgresql-devel
    

    然后再次运行gem install pg

    【讨论】:

      【解决方案2】:

      在 Ubuntu 上,我需要运行:

      sudo apt-get install libpq-dev
      

      【讨论】:

        猜你喜欢
        • 2013-12-28
        • 1970-01-01
        • 1970-01-01
        • 2016-12-06
        • 2012-12-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-10-07
        相关资源
        最近更新 更多