This project is archived and is in readonly mode.

#687 ✓invalid
Gavin Stark

Extend gem:install task to allow for options to the gem command and to the setup of gems

Reported by Gavin Stark | July 24th, 2008 @ 04:17 AM

When installing gems such as mysql I need to pass it options to tell it where to find the libraries and headers on my system.

Also, when I install gems on production boxes I often use --no-ri and --no-rdoc.

The included patch adds a :gem_options which are command line options to be passed to the gem command and :install_options which are passed to the gem setup via the "--" option to gem.


config.gem "mysql", :version => "2.7", :gem_options => "--no-ri --no-rdoc", :install_options => "--with-mysql-config=/usr/local/mysql-5.0.51b-osx10.5-x86/bin/mysql_config"

Comments and changes to this ticket

  • Claudio Poli

    Claudio Poli July 24th, 2008 @ 05:41 PM

    I vote for it, on production boxes there's no need for gem documentation, also the mysql gem always gave this kind of "problem".

    the issue here is that the options may differ from machine to machine, but it's a start.

  • Ryan Bates

    Ryan Bates July 24th, 2008 @ 06:40 PM

    I don't think this belongs in the config file because it is very specific to the system. If you have multiple developers or need to deploy to multiple servers, there's a good chance you'll need it to behave differently.

    Perhaps instead we can have "GEM_OPTIONS" for the gems:install rake task itself? You could then make a capistrano task to run this command with specific options on the specific server to install the gems the way you want.

    That said, giving the ability to specify gem options in the config file doesn't hurt anything, and there very well be options which aren't system dependent. I'm just going by the example in the ticket.

  • Gavin Stark

    Gavin Stark July 24th, 2008 @ 07:05 PM

    The case of needing to supply build options to the mysql gem was the original case I was trying to solve. That install rarely automatically finds the mysql headers and libraries. There was no way to get a one-step clean gems:install without providing options.

    You are correct that this doesn't explicitly deal with options that may be machine specific.

    However, wouldn't this already work with the above:

    config.gem "mysql", :version => "2.7", :install_options => ENV["MYSQL_GEM_INSTALL_OPTIONS"]

    and invoke the gems:install rake task as:

    rake gems:install MYSQL_GEM_INSTALL_OPTIONS="--with-mysql-config=/server/specific/directory"

    or the same via capistrano?

  • Dan Pickett

    Dan Pickett October 22nd, 2008 @ 11:07 PM

    I kind of agree that it's really dependent on the environment. Maybe there should be an established convention for environment variables?

  • PhilT

    PhilT December 15th, 2008 @ 11:44 AM

    I agree this is an environmental issue. Luckily I just found this gem (sorry bad pun).

    Add the following to ~/.gemrc file:

    gem: --no-ri --no-rdoc

    Doing a rake gems:install then doesn't install the docs. I tested it on Ubuntu 8.10 and it works a treat. Obviously, that doesn't solve the install options issue but but it's a step.

  • Norman Timmler

    Norman Timmler January 6th, 2009 @ 01:31 PM

    +1 That patch would really help us to install gems automatically. At the moment we have a custom solution, that is working exactly like that.

  • Frederik Dietz

    Frederik Dietz January 6th, 2009 @ 01:39 PM

    +1 for including this patch.

    The ~/.gemrc solves only partly the problem since it lets you only configure settings which are used each time you run the gem command.

    Gavin's patch introduces a per-gem option which allows to mix even with system environment variables.

    The mysql gem broke the whole thing for me too, BTW. Since I can't specify any additional options, the whole thing can't be used in my special case.

  • A. Jelveh

    A. Jelveh January 7th, 2009 @ 12:38 PM

    +1 for this patch

    though I believe it's correct that server installations and deployment might differ this would be a great start.

  • Rizwan Reza

    Rizwan Reza January 21st, 2010 @ 04:03 PM

    • Milestone cleared.
    • Tag changed from railties to patch, railties, verified
    • State changed from “new” to “invalid”

    Since Rails 3 uses Bundler, this whole discussion doesn't apply.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>