I was able to fix it temporarily by doing this (sorry if the patch file
is kinda screwy, I don't do this very often):
Index: railties/lib/initializer.rb
===================================================================
--- railties/lib/initializer.rb (revision 5721)
+++ railties/lib/initializer.rb (working copy)
@@ -605,6 +605,8 @@
lib
vendor
).map { |dir| "#{root_path}/#{dir}" }.select { |dir|
File.directory?(dir) }
+
+ paths.concat Dir["#{root_path}/vendor/plugins/*/lib/"]
paths.concat builtin_directories
end
If somebody could fix this properly, that would be great.
Thanks,
Martin
I've reverted the change to both edge and 1-2, James, if you can PDI
a fix, that'd be hot :).
--
Cheers
Koz
--
* J *
~
Hi Martin,
The fix you've provided (essentially reverting a part of
http://dev.rubyonrails.org/ticket/6842) will add *all* lib directories
from plugins to the load path, regardless of config.plugins. Can you
please do the following:
a) ensure that you're using a fresh copy of Rails 1.2/trunk, with no
modifications on your side
b) detail which plugins you are using - if your plugins have
interdependencies, that could be an important clue
c) open up a console and give me the output of "puts $LOAD_PATH"
That should be a good starting point. I'm keen to get this fixed ASAP :)
James
Following up on this, I can't replicate Martin's problem. Here are the
steps I took to try:
1. create new rails application
$ cd /tmp
$ rails test_plugin_loading
< ... rails project creation output ... >
$ cd test_plugin_loading
2. check out the version of Rails with patches from #6851 and #6842 installed
$ svn co -r 5720 http://dev.rubyonrails.org/svn/rails/trunk vendor/rails
3. create some sample plugins
$ mkdir vendor/plugins/plugin_a
$ mkdir vendor/plugins/plugin_a/lib
$ echo "puts 'loading plugin a'" > vendor/plugins/plugin_a/init.rb
$ mkdir vendor/plugins/plugin_b
$ echo "puts 'loading plugin b'" > vendor/plugins/plugin_b/init.rb
4. load up script/console
$ script/console
Loading development environment.
loading plugin A
loading plugin B
>> puts $LOAD_PATH
< ... snipped to show the relevant parts ... >
script/../config/../config/../components
script/../config/../config/../config
script/../config/../config/../lib
script/../config/../config/../vendor/plugins/plugin_a/lib/
script/../config/../config/../vendor
/private/tmp/test_loading_plugins/vendor/rails/railties/builtin/rails_info/
script/../config/../config/../vendor/rails/railties
script/../config/../config/../vendor/rails/railties/lib
< ... etc ... >
... as you'd expect, both plugins are loaded, and plugin_a/lib
appears in the load path. Editing config/environment.rb to include
"config.plugins = []", and as expected, no plugins load:
>> exit
$ script/console
Loading development environment.
>>
In this case, no plugins have been loaded, and accordinly
vendor/plugins/plugin_a/lib does NOT appear in the $LOAD_PATH.
My only conclusion here is that the patch works fine, and that the
setup Martin was using somehow relied on the previously-broken
behaviour of having all plugin lib directories in the $LOAD_PATH
before any plugins are actually loaded. I'd suggest that Martin makes
use of config.plugins to fix his application.
It's worth noting that #6851 doesn't affect this issue - can we reapply that?
I am by no means a Rails Core expert, so yes, my analysis might be
wrong. However, after Koz's fix yesterday, I couldn't start up mongrel
anymore, because it was complaining about missing constants (don't have
the exact error message and trace handy).
This happened for some of our own plugins, but also for common plugins
like ExceptionNotifier. We were testing this on a clean version of Edge
Rails, without any special patches.
Martin
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
Exiting
./script/../config/../vendor/rails/activesupport/lib/active_support/
dependencies.rb:263:in `load_missing_constant': uninitialized
constant ExceptionNotifier (NameError)
from ./script/../config/../vendor/rails/activesupport/lib/
active_support/dependencies.rb:447:in `const_missing'
from ./script/../config/../vendor/rails/activesupport/lib/
active_support/dependencies.rb:459:in `const_missing'
from /Users/maym/Projects/loopnote/config/environment.rb:58
from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/
custom_require.rb:21:in `require'
from ./script/../config/../vendor/rails/activesupport/lib/
active_support/dependencies.rb:490:in `require'
from ./script/../config/../vendor/rails/activesupport/lib/
active_support/dependencies.rb:337:in `new_constants_in'
from ./script/../config/../vendor/rails/activesupport/lib/
active_support/dependencies.rb:490:in `require'
from /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.17/lib/
mongrel/rails.rb:156:in `rails'
... 13 levels...
from ./script/../config/../vendor/rails/activesupport/lib/
active_support/dependencies.rb:337:in `new_constants_in'
from ./script/../config/../vendor/rails/activesupport/lib/
active_support/dependencies.rb:490:in `require'
from ./script/../config/../vendor/rails/railties/lib/
commands/server.rb:39
from script/server:3
Hope that helps,
Martin
Found the problem - because we weren't adding ALL plugin lib
directories as default_load_paths, they weren't getting added to
Dependencies.load_paths (which is where the automatic constant loading
magic is based).
I've updated the ticket (#6842) with a new patch that explicitly adds
plugin lib directories to the Dependencies mechanism - Koz, can you
apply #6842 and #6851 again?
Cheers!
Thanks,
Martin
--
Cheers
Koz