#5 new
Philippe

Error on click to globalize plugin loading

Reported by Philippe | September 11th, 2008 @ 12:14 AM

When I installed click to globalize, I had the following message when I tried to use my project ('rake click:test', 'script/server', etc.) : C:/Applications/Dev/ruby-186-25/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails/plugin/loader.rb:149:in ensure_all_registered_plugins_are_loaded!': Could not locate the following plugins: helper_test and globalize (LoadError)

    from C:/Applications/Dev/ruby-186-25/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails/plugin/loader.rb:39:in `load_plugins'
    from C:/Applications/Dev/ruby-186-25/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:189:in `load_plugins'
    from C:/Applications/Dev/ruby-186-25/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:105:in `process'
    from C:/Applications/Dev/ruby-186-25/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:49:in `send'
    from C:/Applications/Dev/ruby-186-25/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:49:in `run'
    from S:/Soovenir/web_site/vendor/plugins/click_to_globalize/init.rb:8:in `evaluate_init_rb'
    from C:/Applications/Dev/ruby-186-25/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:79:in `evaluate_init_rb'
    from C:/Applications/Dev/ruby-186-25/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/kern

el/reporting.rb:11:in silence_warnings'

     ... 21 levels...
    from C:/Applications/Dev/ruby-186-25/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39
    from C:/Applications/Dev/ruby-186-25/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_requi

re'

    from C:/Applications/Dev/ruby-186-25/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
    from script/server:3

Tracing the code, I found an inconsistency in click_to_globalize/init.rb. Since it wants to make sure that Click is loaded after Globalize, it basicaly says "load everything but me". Since Globalize is part of "everything but me", it's fine.

The problem occurs in the way "everything but me" is computed: plugins = (Dir["#{config.plugin_paths}/*"] - [ File.dirname(FILE) ]).map { |plugin| plugin.split(File::SEPARATOR).last}

This piece of code assumes that any directory under vendor/plugins is a plugin. But if you look at Rails::Plugin.valid?, it is slightly more complicated: a valid plugin has a lib directory or an init.rb file. And it appears that one of my installed plugins, helper_test, is not "valid" if we follow the Plugin definition, thus causing an error when Click "forces" it.

To make the Click trick more robust, I copied/pasted Rails::Loader.locate_plugins method (which is unfortunately protected) :

Get the plugin list the Rails::Plugin's way

plugins = config.plugin_locators.map { |locator|

        locator.new(initializer).plugins.map {|plugin| plugin.name}
      }.flatten

Remove Click from the list

plugins = plugins - [File.dirname(FILE).split(File::SEPARATOR).last]

(sorry, no patch to submit... but if you want to use this solution as is, you can probably do it without too much efforts :) )

Cheers,

Philippe

Comments and changes to this ticket

  • Luca Guidi

    Luca Guidi September 11th, 2008 @ 09:24 AM

    • Tag set to bug

    Thanks for reporting. I'm figuring how to solve this issue, it affects a lot of applications, lately. Maybe the right solution is to completely remove all the code from init.rb (except for the require statement) and add to your environment.rb the following line:

    
    config.plugins = [ :all, "click-to-globalize".to_sym ]
    

    Probably I'll add the code to prompt a warning message after the installation process.

  • Philippe

    Philippe September 12th, 2008 @ 11:19 PM

    Thank you for your answer.

    I tried your workaround and I was not able to make it run. When I start rake click:test, I have:

    S:/my_web_site/vendor/plugins/click_to_globalize/lib/click_to_globalize.rb:5:in alias_method': undefined method translate' for class Class' (NameError)

        from S:/my_web_site/vendor/plugins/click_to_globalize/lib/click_to_globalize.rb:5
        from C:/Applications/Dev/ruby-186-25/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_requi
    
    

    re'

        from C:/Applications/Dev/ruby-186-25/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from C:/Applications/Dev/ruby-186-25/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.
    
    

    rb:496:in require'

        from C:/Applications/Dev/ruby-186-25/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.
    
    

    rb:342:in new_constants_in'

        from C:/Applications/Dev/ruby-186-25/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.
    
    

    rb:496:in require' ...

    I didn't trace the problem, but the message makes me feel that Globalize has not be loaded yet... I was wondering: in your line of code above, does not :all contain Click? In other words, do you load Click last, or do you load it twice (first time because of :all, second time because of the explicit symbol)?

  • Luca Guidi

    Luca Guidi September 12th, 2008 @ 11:58 PM

    http://github.com/rails/rails/tr...

    ":all can be used as a placeholder for all plugins not explicitly named"

    Try to include Globalize in init.rb and look it was effectively missing.

  • Philippe

    Philippe September 13th, 2008 @ 12:21 AM

    Oops! Documentation was not that far... sorry.

    It works actually: it's just that I have a vendor/plugins/click_to_globalize directory and not vendor/plugins/click-to-globalize, so for me it's:

    config.plugins = [ :all, :click_to_globalize ]

    Thank you,

    Philippe

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Click to Globalize is an extension for Globalize plugin, it allows to edit in place globalized labels. With this plugin you don't have to create a
globalization back-end, but just edit your interface in place!!

People watching this ticket

Tags

Pages