Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#687

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.

Example:

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"

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

State: invalid
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Claudio Poli
    Claudio Poli

    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.

    July 24th, 2008 @ 05:41 PM

  2. Ryan Bates
    Ryan Bates

    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.

    July 24th, 2008 @ 06:40 PM

  3. Gavin Stark
    Gavin Stark

    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?

    July 24th, 2008 @ 07:05 PM

  4. Dan Pickett
    Dan Pickett

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

    October 22nd, 2008 @ 11:07 PM

  5. PhilT
    PhilT

    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.

    December 15th, 2008 @ 11:44 AM

  6. Norman Timmler
    Norman Timmler

    +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.

    January 6th, 2009 @ 01:31 PM

  7. Frederik Dietz
    Frederik Dietz

    +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.

    January 6th, 2009 @ 01:39 PM

  8. A. Jelveh
    A. Jelveh

    +1 for this patch

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

    January 7th, 2009 @ 12:38 PM

  9. Rizwan Reza
    Rizwan Reza
    • 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.

    January 21st, 2010 @ 04:03 PM