gem install pg --with-pg-config工作,bundle失败

YuK*_*agi 69 postgresql rubygems bundler pg

当我跑(以root身份)

gem install pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config
Run Code Online (Sandbox Code Playgroud)

我得到以下输出:

#-> gem instal pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config
Building native extensions.  This could take a while...
Successfully installed pg-0.12.0
1 gem installed
Installing ri documentation for pg-0.12.0...
Installing RDoc documentation for pg-0.12.0...
#-> 
Run Code Online (Sandbox Code Playgroud)

当我运行bundle install时:

Installing pg (0.12.0) with native extensions 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /usr/local/rvm/rubies/ruby-1.9.2-p290/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.

Provided configuration options:
--with-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=/usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby
--with-pg
--without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include=${pg-dir}/include
--with-pg-lib
--without-pg-lib=${pg-dir}/lib
--with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config


Gem files will remain installed in /var/www/simpletrac/vendor/cache/ruby/1.9.1/gems/pg-    0.12.0 for inspection.
Results logged to /var/www/simpletrac/vendor/cache/ruby/1.9.1/gems/pg-0.12.0/ext/gem_make.out
An error occured while installing pg (0.12.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.12.0'` succeeds before bundling.
Run Code Online (Sandbox Code Playgroud)

我在/usr/pgsql-9.1/include/libpq-fe.h上安装了libpq-fe.h.所以,我试过了

gem install pg -v '0.12.0' -- --with-pg-config=/usr/pgsql-9.1/bin/pg_config --with-pg-lib=/usr/pgsql-9.1/include/libpq-fe.h but still no go. 
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激.

另外,我安装了postgresql91-devel和ruby-devel.运行CentOS 6.

Joh*_*rug 173

你有没有尝试在跑步之前运行它bundle install

bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config
Run Code Online (Sandbox Code Playgroud)

请参见http://bundler.io/v1.3/bundle_config.html

  • 在CentOS 6上工作就像一个魅力!只需要在整个安装完全成功之前运行`yum install postgresql-devel`! (2认同)
  • 另外 `--with-pg-dir=/usr/pgsql-<version>` 处理配置和库。 (2认同)

Les*_*ial 18

如果有人使用macport来安装postgres并且在查找pg_config时遇到问题,请尝试以下方法:

bundle config build.pg --with-pg-config=/opt/local/lib/postgresql91/bin/pg_config
Run Code Online (Sandbox Code Playgroud)

我希望这有助于节省一些时间.干杯!


Jai*_*put 11

如果您不确定pg_config的位置,并假设您使用的是Linux或Mac,则可以运行以下命令:

which pg_config
Run Code Online (Sandbox Code Playgroud)

这将返回==> /usr/pgsql-9.1/bin/pg_config

现在使用此路径作为

bundle config build.pg --with-pg-config=/usr/pgsql-9.1/bin/pg_config
Run Code Online (Sandbox Code Playgroud)

现在完成 bundle install


Ina*_*mus 6

复制粘贴:

bundle config build.pg --with-pg-config=`which pg_config` && bundle
Run Code Online (Sandbox Code Playgroud)

细节:

访问以获取更多信息:

您应该做的第一件事是确保Postgres附带的'pg_config'工具在您的路径中.如果不是,或者您的路径中的第一个不是与要构建的Postgres一起安装的那个,则可以使用-with-pg-config选项指定它的路径.

资料来源: https ://github.com/ged/ruby-pg/blob/1f274f68c16f1af1c642db1b9d3d28aef169dc84/ext/extconf.rb#L27


And*_*dyM 5

如果您安装了 pg_config 但它不在任何路径中,您可能会收到此错误。您可以将其添加到 ~/.bashrc 中的 PATH 环境中。

例如。

export PATH=${PATH}:/usr/pgsql-9.2/bin
Run Code Online (Sandbox Code Playgroud)


sup*_*ary 5

Postgres gem 找不到 Postgres 配置文件。你需要告诉它它在哪里。在我看来,最令人愉快的解决方案是跳过 Brew 和 MacPorts,只使用 Postgres 应用程序。从这里下载并安装:

http://postgresapp.com/

现在将 bin 文件夹添加到您的路径中:

PATH="/Applications/Postgres.app/Contents/MacOS/bin:$PATH"
Run Code Online (Sandbox Code Playgroud)

您可能还希望将其添加到您的 ~/.bash_profile 中

现在安装宝石:

gem install pg
Run Code Online (Sandbox Code Playgroud)

应该会进展顺利。