Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: Options for build bundler gemfile

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

like image 429
23tux Avatar asked Feb 06 '12 19:02

23tux


People also ask

How do I use Gemfile in Ruby?

run the command bundle install in your shell, once you have your Gemfile created. This command will look your Gemfile and install the relevant Gems on the indicated versions. The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from.

What is Gemfile in Ruby on Rails?

A Gemfile is a file that is created to describe the gem dependencies required to run a Ruby program. A Gemfile should always be placed in the root of the project directory.

What is the difference between Gemfile and Gemfile lock?

The Gemfile is where you specify which gems you want to use, and lets you specify which versions. The Gemfile. lock file is where Bundler records the exact versions that were installed. This way, when the same library/project is loaded on another machine, running bundle install will look at the Gemfile.

Where is Gemfile in Ruby on Rails?

A Gemfile describes the gem dependencies required to execute associated Ruby code. Place the Gemfile in the root of the directory containing the associated code. For instance, in a Rails application, place the Gemfile in the same directory as the Rakefile .


1 Answers

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

like image 135
Steve Benner Avatar answered Oct 10 '22 19:10

Steve Benner