当我运行bundle install时,如何为gem安装传递参数?

时间:2011-03-02 13:01:52

标签: ruby-on-rails ruby-on-rails-3 gem bundler

我将pg gem添加到我的gemfile

gem 'pg'

当我运行bundle install时,我收到此错误:

Installing pg (0.10.1) with native extensions /Users/ben/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/rubygems/installer.rb:483:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError)

/Users/benhartney/.rvm/rubies/ruby-1.9.2-p0/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.

似乎我需要传递这个配置参数

 --with-pg-config=/path/to/pg_config

当我使用bundle install时,我该怎么做?

4 个答案:

答案 0 :(得分:82)

您需要设置一个构建配置选项,如下所示:

bundle config build.pg --with-pg-config=/path/to/pg_config

可以在bundle config man page

中找到更多信息

答案 1 :(得分:15)

在'bundle install'之前运行'bundle config'来设置参数,即:

bundle config build.pg --with-pg-config=/path/to/pg_config
bundle install

答案 2 :(得分:9)

Rails3 PostgreSQL 。我喜欢这个

>rails new test_app -d postgreSQL
>cd test_app
>mkdir .bundle
>echo "BUNDLE_BUILD__PG: --with-pg-config=/opt/local/lib/postgresql91/bin/pg_config" > .bundle/config
>bundle install

所以你可以在源代码管理中保持配置。

用户个人资料的

bundle config build.pg --with-pg-config=/opt/local/lib/postgresql91/bin/pg_config

这将创建〜/ .bundle / config文件。

答案 3 :(得分:0)

如果您正在使用Ruby 2.x及更高版本,则thrift 0.9.0无法使用它构建。见https://issues.apache.org/jira/browse/THRIFT-2219。节俭0.9.2是固定的。

尝试安装: gem install rbhive -v 1.0.3.pre