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.

gem install fails when a gem requires multiple sources

#3048

I have a gem on github. It depends on a gem at rubyforge.

  config.gem 'mperham-right_aws', :source => 'http://gems.github.com', :version => '1.10.1', :lib => 'right_aws'

This will fail to install via rake gems:install since the source parameter overrides any other RubyGems sources so gem will not look at rubyforge for the dependency. I think the simplest fix is to just add rubyforge as an additional source if a source is specified:

rails-2.3.3/lib/rails/gem_dependency.rb:285

      def install_command
        cmd = %w(install) << name
        cmd << "--version" << %("#{requirement.to_s}") if requirement
        cmd << "--source"  << @source  if @source
+       cmd << "--source"  << 'http://gems.rubyforge.org' if @source
        cmd
      end

My gem installs as expected with this change.

Reported by Mike Perham · August 13th, 2009 @ 07:01 PM

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

Activity

  1. Matt Jones
    Matt Jones

    This is not a correct behavior - we don't want to be hardcoding gem server locations. It's actually a known issue in RubyGems, not Rails. The correct thing to do here would be to extract all of the gem sources that Rubygems knows about and add them all to the string - maybe you'd be interested in writing that patch?

    I'd also point out that the :source option is only required if the user doesn't have gems.github.com added as a source globally; that's a lot more likely now than it was, say, a year ago.

    August 17th, 2009 @ 03:59 PM

  2. Mike Perham
    Mike Perham

    Agreed that this is a RubyGems bug. I'll write the patch if I have some free time soon.

    August 17th, 2009 @ 04:25 PM

  3. Mike Perham
    Mike Perham

    Patch to add all Gem.sources to cmd line.

    August 17th, 2009 @ 11:46 PM

  4. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from gem to bugmash, gem

    September 25th, 2009 @ 12:52 PM

  5. Erik Ostrom
    Erik Ostrom

    +1 verified the behavior, the test, and the patch. Seems like this is a good workaround for a failing in RubyGems.

    September 26th, 2009 @ 05:19 AM

  6. Elise Huard
  7. Matt Jones
    Matt Jones

    The patch looks reasonable, but there's one case I'm a little concerned about: what if there's a gem name collision between the various pre-configured servers? In other words, gems.rubyforge.org has a gem named SomeGem, and another server also has one with the same name (potentially different versions; possibly even different authors).

    The Rubygems interpretation of --source will allow a user to disambiguate which one they mean, but this patch removes that functionality. Maybe an :exclusive_source option would be handy as well?

    September 26th, 2009 @ 08:38 PM

  8. Rizwan Reza
    Rizwan Reza
    • State changed from new to wontfix
    • Tag changed from bugmash, gem to gem

    I think this is out of question as Rails 3.0 is using Bundler (or Bubble).

    January 21st, 2010 @ 07:15 AM