当我运行软件包安装时,如何传递一个用于gem安装的参数?

我添加了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. 

看来我需要通过这个configuration参数

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

我使用bundle install时如何执行此操作?

你需要像这样设置一个构buildconfiguration选项:

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

更多信息可以在软件包configuration手册页find

在“bundle install”之前运行“bundle config”来设置参数,例如:

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

Rails3PostgreSQL 。 我喜欢这个

 >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 

所以你可以在源代码控制中保持configuration。

为用户的configuration文件

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

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

如果你使用Ruby 2.x或更高版本,那么节俭0.9.0就不能用它构build。 请参阅https://issues.apache.org/jira/browse/THRIFT-2219 。 节俭0.9.2是固定的。

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