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.

config.gem does not scope search to gems path

#1777

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

Reported by Peregrinator · January 17th, 2009 @ 07:44 PM

State: stale
Milestone: 2.x
Assigned to: Matt Jones Matt Jones
Importance: none

Activity

  1. Matt Jones
    Matt Jones
    • 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?

    February 18th, 2009 @ 01:37 AM

  2. David Dollar
    David Dollar

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

    March 27th, 2009 @ 07:11 PM

  3. Ryan Bigg
    Ryan Bigg
    • State changed from new to stale

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

    April 29th, 2010 @ 10:24 PM