Rails: Options for build bundler gemfile

2019-03-19 21:28发布

I have a gem, that must be build with some options.

gem install pg --with-pg-include=/Library/PostgreSQL/9.0/include/ --with-pg-lib=/Library/PostgreSQL/9.0/lib/

Can I include this options in the Gemfile? In my Gemfile the pg command is

gem "pg", "0.12.2"

I want to provide some options after the version number.

thx, tux

1条回答
The star\"
2楼-- · 2019-03-19 21:51

Here is the relevant text from the link posted in comments already:

BUILD OPTIONS

You can use bundle config to give bundler the flags to pass to the gem installer every time bundler tries to install a particular gem.

A very common example, the mysql gem, requires Snow Leopard users to pass configuration flags to gem install to specify where to find the mysql_config executable.

gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Since the specific location of that executable can change from machine to machine, you can specify these flags on a per-machine basis.

bundle config build.mysql --with-mysql-config=/usr/local/mysql/bin/mysql_config

After running this command, every time bundler needs to install the mysql gem, it will pass along the flags you specified.

Here is another example of custom build options, in this case specifying a specific source to download from other than rubygems:

bundle config build.popen4 --source http://gemcutter.org

查看更多
登录 后发表回答