Current Edge breaks plugin loads

3 views
Skip to first unread message

Hiro Protagonist

unread,
Dec 15, 2006, 7:58:29 PM12/15/06
to Ruby on Rails: Core

In revision 5720, NZKoz checked in some stuff that is supposed to use
config.plugins for loading plugin s in the right order. I think he
intended it to keep working the way it is if config.plugins is not set,
but at least for me, no plugins are being loaded at all with this
change.

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

Michael Koziarski

unread,
Dec 15, 2006, 11:37:31 PM12/15/06
to rubyonra...@googlegroups.com
> In revision 5720, NZKoz checked in some stuff that is supposed to use
> config.plugins for loading plugin s in the right order. I think he
> intended it to keep working the way it is if config.plugins is not set,
> but at least for me, no plugins are being loaded at all with this
> change.

I've reverted the change to both edge and 1-2, James, if you can PDI
a fix, that'd be hot :).

--
Cheers

Koz

James Adam

unread,
Dec 16, 2006, 6:30:00 AM12/16/06
to rubyonra...@googlegroups.com
I'm on it.


--
* J *
~

James Adam

unread,
Dec 16, 2006, 6:36:07 AM12/16/06
to rubyonra...@googlegroups.com, Hiro...@gmail.com
On 12/16/06, Hiro Protagonist <Hiro...@gmail.com> wrote:
> In revision 5720, NZKoz checked in some stuff that is supposed to use
> config.plugins for loading plugin s in the right order. I think he
> intended it to keep working the way it is if config.plugins is not set,
> but at least for me, no plugins are being loaded at all with this
> change.

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

James Adam

unread,
Dec 16, 2006, 10:43:12 AM12/16/06
to rubyonra...@googlegroups.com
On 12/16/06, James Adam <james...@gmail.com> wrote:
> On 12/16/06, Hiro Protagonist <Hiro...@gmail.com> wrote:
> > In revision 5720, NZKoz checked in some stuff that is supposed to use
> > config.plugins for loading plugin s in the right order. I think he
> > intended it to keep working the way it is if config.plugins is not set,
> > but at least for me, no plugins are being loaded at all with this
> > change.

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?

Hiro Protagonist

unread,
Dec 16, 2006, 3:26:22 PM12/16/06
to Ruby on Rails: Core
Hi James,

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

Martin May

unread,
Dec 16, 2006, 3:31:52 PM12/16/06
to rubyonra...@googlegroups.com

Here's the error I am seeing, in this case with the exception
notifier plugin:

=> 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

James Adam

unread,
Dec 16, 2006, 9:40:25 PM12/16/06
to rubyonra...@googlegroups.com
On 12/16/06, Martin May <Hiro...@gmail.com> wrote:
> ./script/../config/../vendor/rails/activesupport/lib/active_support/
> dependencies.rb:263:in `load_missing_constant': uninitialized
> constant ExceptionNotifier (NameError)

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!

Hiro Protagonist

unread,
Dec 17, 2006, 10:55:09 PM12/17/06
to Ruby on Rails: Core
I can confirm that the new patch seems to fix things for me.

Thanks,
Martin

Michael Koziarski

unread,
Dec 18, 2006, 5:31:41 PM12/18/06
to rubyonra...@googlegroups.com
Committed. Let me know if there are any other issues.


--
Cheers

Koz

Reply all
Reply to author
Forward
0 new messages