[Rubygems-developers] dependent gems not installed when using a --source gem repository

Stephen Bannasch stephen.bannasch at deanbrook.org
Fri May 16 13:00:10 EDT 2008

At 12:37 AM -0700 5/15/08, Eric Hodel wrote:
>On May 12, 2008, at 10:04 AM, Stephen Bannasch wrote:
>>I've got an alpha gem I am working on called make_models and I'm hosting it now on my own gem repository. Both main and arrayfields are gem dependencies of make_models.  If I download it and install from a file the dependencies are resolved.
>>I got this report from someone else who tried to install it from my gem repository without having the prerequisite gems:
>>>sudo gem install make_models --source=http://rails.dev.concord.org/gems/
>>>I get this error:
>>>(9:27:59) [tikal:/web/rails] pburney% sudo gem install make_models --source=http://rails.dev.concord.org/gems/
>>>Bulk updating Gem source index for: <http://rails.dev.concord.org/gems/>http://rails.dev.concord.org/gems/
>>>ERROR:  Error installing make_models:
>>>     make_models requires main (>= 2.8.0)
>>Has anybody else seen this problem?
>There is no main gem in that gem repository.  Either add main to that repository, or include both that repository and your repository as sources.

I had assumed that the installed source repositories (default and any installed with gem sources --add) would be included in the search strategy used for dependency resolution.

It wasn't immediately obvious how to to specify two or more gem repositories to use for resolving install dependencies without making them permanent.

I looked at the code in local_remote_options.rb:


  # Add the --source option
  def add_source_option

    add_option(:"Local/Remote", '--source URL', URI::HTTP,
               'Use URL as the remote source for gems') do |value, options|
      if options[:added_source] then
        Gem.sources << value
        options[:added_source] = true
        Gem.sources.replace [value]

OK ... now I understand ...

Here's a doc diff that adds a bit more explanation about how it currently works:

$ svn diff lib/rubygems/local_remote_options.rb
Index: lib/rubygems/local_remote_options.rb
--- lib/rubygems/local_remote_options.rb	(revision 1715)
+++ lib/rubygems/local_remote_options.rb	(working copy)
@@ -73,7 +73,8 @@
     add_option(:"Local/Remote", '--source URL', URI::HTTP,
-               'Use URL as the remote source for gems') do |value, options|
+               'Use URL as the remote source for gems instead of installed sources'
+               'this option may be used multiple times to specify additional sources') do |value, options|
       if options[:added_source] then
         Gem.sources << value


And for anybody finding this later with Google here's a specific answer:

I've already uninstalled my gem make_models. The gem arrayfields is a dependency for make_models but is not in my repository. I'm uninstalling it for this test.

  $ sudo gem uninstall arrayfields

Now specifying both the default rubygems repository and my own repository (where make_models is hosted) installs the make_models gem from my custom repository and arrayfields from the rubygems repository.

  $ sudo gem install make_models --source=http://gems.rubyforge.org/ --source=http://rails.dev.concord.org/gems/

  Updating metadata for 2 gems from http://rails.dev.concord.org/gems/
  Successfully installed arrayfields-4.5.0
  Successfully installed make_models-
  2 gems installed
  Installing ri documentation for make_models-
  Installing RDoc documentation for make_models-

More information about the Rubygems-developers mailing list