无法捆绑Postgresql

时间:2016-01-17 17:10:51

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

尝试运行捆绑安装时出现以下错误

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安装postgresql,但它告诉我它已经安装但没有链接。

然后我尝试了brew链接postgresql,但它告诉我:

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

不确定如何继续。 :(

1 个答案:

答案 0 :(得分:2)

如果您使用的是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为您提供安装它的文件路径。