This project is archived and is in readonly mode.
Gem plugins, autoloading, and dev mode reloading
-
Matt Jones
Putting this code in initializers/gem_hook.rb
module GemHook def self.included(base) #:nodoc: base.instance_eval do unless defined? gem_without_load_once_paths alias_method_chain :gem, :load_once_paths end end end def gem_with_load_once_paths(gem_name, *version_requirements) old_load_paths = $LOAD_PATH.dup result = gem_without_load_once_paths(gem_name, *version_requirements) new_load_paths = $LOAD_PATH.dup added_paths = new_load_paths - old_load_paths ActiveSupport::Dependencies.load_paths |= added_paths ActiveSupport::Dependencies.load_once_paths |= added_paths result end end Kernel.instance_eval { include GemHook }makes the behavior consistent. It would be straightforward to incorporate this into dependencies.rb, but how would this function be tested?
-
Matt Jones
- Tag changed from 2.2-stable, autoload, dependencies, gems to 2.2-stable, autoload, bug, dependencies, gems
- Title changed from Gem plugins and dev mode reloading to Gem plugins, autoloading, and dev mode reloading
On further investigation, this is a more serious problem - loadable_constants_for_path won't find constants defined in gems that aren't loaded with config.gem. This should either be fixed (similar to above) or documented clearly.
-
DHH
- Assigned user set to josh
-
josh
- Assigned user changed from josh to Jeremy Kemper
-
Michael Koziarski
- Milestone cleared.
-
Yehuda Katz (wycats)
- Milestone cleared.
-
Yehuda Katz (wycats)
- Assigned user changed from Jeremy Kemper to Yehuda Katz (wycats)
We're going to take a fresh look at reloading and gem plugins in general in 3.0. We'll make sure to address all open concerns about them.