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.

Vendored Gems Not Being Activated With Rake Tasks

#2204

Observed in rails >=2.3 when rails gems are vendored.

When Rakefile calls boot.rb, load_initializer (for class VendorBoot) will stub gem specs, but will not add_gem_load_paths.

If you have another gem that requires a vendored gem, you will receive an error message like..

rake -T

rake aborted!

can't activate activesupport (>= 2.0.0, runtime), already activated activesupport-2.3.1

Before Fix

def load_initializer

 require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"

 Rails::Initializer.run(:install_gem_spec_stubs)

end

After Fix

def load_initializer

 require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"

 Rails::Initializer.run(:install_gem_spec_stubs)

 Rails::Initializer.run(:add_gem_load_paths)

end

Reported by John Dzak · March 10th, 2009 @ 10:24 PM

State: resolved
Milestone: none
Assigned to: Matt Jones Matt Jones
Importance: High

Activity

  1. Matt Jones
    Matt Jones
    • Assigned user set to Matt Jones

    It would be more descriptive to run Rails::GemDependency.add_frozen_gem_paths directly, as that's whats accomplished here. Calling add_gem_load_paths implies that config.gem stuff is getting loaded, which is not the case.

    I'm curious, however, how you encountered this error. What gems are you using, and do you have 'require' and/or 'gem' statements in your rake tasks?

    March 11th, 2009 @ 10:51 AM

  2. John Dzak
    John Dzak

    Ah cool, thanks.

    So we encounter this error when a rake tasks in our rails project loads another task which is housed in a gem we wrote. That task eventually calls require 'activesupport' and that is where we encounter the problem.

    BTW, this will only happen if the 2.3.1 gems that are vendored are not installed in rubygems. We noticed the problem on a machine that only had the 2.2.2 gems installed.

    March 11th, 2009 @ 04:43 PM

  3. Matt Jones
    Matt Jones

    Does add_frozen_gem_paths solve the problem? 2.3 is right around the corner, and it would be good to get a patch in.

    March 12th, 2009 @ 09:44 AM

  4. John Dzak
    John Dzak

    Yep, working on the patch right now.

    March 12th, 2009 @ 06:59 PM

  5. John Dzak
  6. John Dzak
    John Dzak

    Ooops, scratch that last patch. Picked up the wrong file.

    March 12th, 2009 @ 08:25 PM

  7. Matt Jones
    Matt Jones
    • Milestone cleared.

    +1 Looks good to me!

    March 12th, 2009 @ 08:44 PM

  8. Repository
    Repository
    • State changed from new to resolved

    (from [9d906707bea997016fd370e33e12dbc21cfcc531]) Vendored gem paths now being loaded if they exist [#2204 Vendored Gems Not Being Activated With Rake Tasks state:resolved]

    Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...

    March 13th, 2009 @ 10:25 AM