【问题标题】:Can't bundle Postgresql无法捆绑 Postgresql
【发布时间】:2016-01-17 17:10:51
【问题描述】:

尝试运行 bundle install 时出现以下错误

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/seque1990/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/pg-0.18.4/ext
/Users/seque1990/.rbenv/versions/2.2.2/bin/ruby -r ./siteconf20160117-46131-1dmnnnq.rb extconf.rb --with-pg-config=/opt/local/lib/postgresql91/bin/pg_config
Using config values from /opt/local/lib/postgresql91/bin/pg_config
sh: /opt/local/lib/postgresql91/bin/pg_config: No such file or directory
sh: /opt/local/lib/postgresql91/bin/pg_config: No such file or directory
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=/Users/seque1990/.rbenv/versions/2.2.2/bin/$(RUBY_BASE_NAME)
    --with-pg
    --without-pg
    --enable-windows-cross
    --disable-windows-cross
    --with-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:

  /Users/seque1990/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0-static/pg-0.18.4/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/seque1990/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/pg-0.18.4 for inspection.
Results logged to /Users/seque1990/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/extensions/x86_64-darwin-15/2.2.0-static/pg-0.18.4/gem_make.out

得到它之后,我确实 brew install postgresql 但它告诉我它已经安装但没有链接。

然后我尝试了 brew link postgresql 但它告诉我:

错误:无法符号链接 share/man/man3/SPI_connect.3 /usr/local/share/man/man3 不可写。

不确定如何继续。 :(

【问题讨论】:

    标签: ruby-on-rails postgresql ruby-on-rails-4


    【解决方案1】:

    如果你使用的是 ubuntu 机器,那么,

    sudo apt-get install postgresql
    sudo apt-get install libpq-dev
    

    然后,gem install pg

    对于 oSx,需要指定 pg_config 路径

    gem install pg -- --with-pg-config=`which pg_config`
    

    which pg_config 为您提供安装它的文件路径。

    【讨论】:

      猜你喜欢
      • 2017-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-13
      • 2014-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多