【问题标题】:Unable to install PG gem on Fedora 17无法在 Fedora 17 上安装 PG gem
【发布时间】:2012-12-02 01:56:43
【问题描述】:

pg gem 很顽固,所以我无法在新计算机上加载我的应用程序。似乎有多个问题,无法找到 pg_config 和 extconf.rb

#psql working...
psql (9.2.1)
Type "help" for help.

nd =>
\q

$ pg_config:

#adding the path to bashrc...
$ nano .bashrc

PATH=/usr/pgsql-9.2/bin:$PATH

#seems to work...
pg_config: /usr/pgsql-9.2/bin/pg_config

$ sudo gem install pg

#but i get the same errors...
Building native extensions.  This could take a while...
.......
ERROR:  Error installing pg:
        ERROR: Failed to build gem native extension.

        /usr/bin/ruby 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.

那里有任何处理过这个问题的 linux 人吗?

【问题讨论】:

    标签: ruby-on-rails linux postgresql rvm fedora


    【解决方案1】:

    这个问题解决了

    $ yum install /usr/include/libpq-fe.h
    

    【讨论】:

      【解决方案2】:

      对于 Fedora 20+,需要以下软件包:

      sudo yum install postgresql-devel
      

      【讨论】:

        【解决方案3】:

        对于 Fedora 30:

        $sudo dnf install libpq-devel
        

        然后:

        $gem install pg
        
        Building native extensions. This could take a while...
        Successfully installed pg-1.1.4
        Parsing documentation for pg-1.1.4
        Installing ri documentation for pg-1.1.4
        Done installing documentation for pg after 1 seconds
        1 gem installed
        

        【讨论】:

          【解决方案4】:

          ~嗨

          我在我的 Rails 项目中安装 gem“pg”时遇到了同样的问题,当运行命令“bundle install”时出现同样的错误,在我的情况下,partiuclar 解决它如下:

          我用的是Fedora 19,我猜在Fedora 17中也可以用同样的方法解决:

          我使用以下教程安装了 Postgres:

          然后,我在 ~/.bashrc 中添加了下一行来解决 pg_config 的问题:

          • PATH = / usr/pgsql-9.2/bin: $ PATH

          最后为了解决libpq-fe.h的问题,我安装了postgresql-devel如下:

          • # yum install postgresql92-devel

          最后在我的 Rails 项目中运行命令“bundle install”并且没有更多错误。

          【讨论】:

            猜你喜欢
            • 2016-03-27
            • 2020-02-28
            • 2013-02-20
            • 2015-03-16
            • 1970-01-01
            • 2014-08-27
            • 2012-08-29
            相关资源
            最近更新 更多