This project is archived and is in readonly mode.

#1777 ✓stale
Peregrinator

config.gem does not scope search to gems path

Reported by Peregrinator | January 17th, 2009 @ 07:44 PM | in 2.x

Currently if a gem is required via config.gem the entire gem load paths are searched for the library.

This means that if you require a gem as follows:

config.gem 'backupgem', :lib => 'backup'

All gem paths will be searched until the first file named backup.rb is found in a gem lib folder (ie ruby/1.8/gems/backupgem-1.1.1/lib).

Unfortunately this means that if gem A has a file in it's lib folder with the same name as the expected lib file for gem B and gem A's directory is searched first then that file will be loaded resulting in the gem config passing but not actually requiring the appropriate gem.

Expected behavior would be that only the specified gem's path required in config.gem would be searched. While this is not a problem for many gems, the more gems required increases the likelihood that conflicts will arise.

This behavior has been observed in rails 2.2

Comments and changes to this ticket

  • Matt Jones

    Matt Jones February 18th, 2009 @ 01:37 AM

    • Assigned user set to “Matt Jones”

    The search path is not really something that we have that level of control over; note that a gem that triggers this is going to have problems anyways; the typical way of including many gems is

    
    require 'filename'
    

    Which will automatically find the most recent gem that has that file. The idea (followed by most gems) is to have the filename be specific to the gem (in your case, it should be backupgem.rb or similar).

    Can you provide a specific example of a gem that has this problem?

  • David Dollar

    David Dollar March 27th, 2009 @ 07:11 PM

    This definitely appears to be more of general gems issue rather than a Rails issue.

  • Ryan Bigg

    Ryan Bigg April 29th, 2010 @ 10:24 PM

    • State changed from “new” to “stale”

    Please re-open with an example if this is still causing problems.

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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages