#28 ✓resolved
Diego Algorta

code_paths don't work anymore

Reported by Diego Algorta | August 18th, 2008 @ 07:55 PM

I'm upgrading my app from rails 1.2.6 to 2.1, and for that I've upgraded engines from 1.2.2 to 2.1 too.

In a custom plugin named "my_great_engine_plugin" I have this in init.rb:

I changed Rails.plugins to Engines.plugins as recommended

in the new engines version.

Engines.plugins[:my_great_engine_plugin].code_paths += ["app/exceptions", "app/drops"]

Sadly... that doesn't work now. It fails on startup with:

vendor/plugins/my_great_engine_plugin/init.rb:26:in evaluate_init_rb': You have a nil object when you didn't expect it! (NoMethodError) The error occurred while evaluating nil.code_paths from ./script/../config/../vendor/rails/railties/lib/rails/plugin.rb:95:inevaluate_init_rb'

from vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'

I debugged and got to the conclussion that Engines.plugins does have the already loaded plugins, but it still doesn't include the current plugin while running it's init.rb.

Comments and changes to this ticket

  • Diego Algorta

    Diego Algorta August 18th, 2008 @ 08:45 PM

    I was able to add the paths in init.rb by using self.code_paths instead of Engines.plugins[:my_plugin].code_paths.

    But... even that way... by the time init.rb is ran it's too late because rails 2.1 in Initializer#process executes add_plugin_load_paths BEFORE load_plugins.

    That way, my added paths never get added to the load_path.

  • James Adam

    James Adam September 13th, 2008 @ 10:05 AM

    • State changed from “new” to “open”

    I'm not sure about the future of code_paths. Since it's quite possible (and easy) to add additional paths to the $LOAD_PATH without any special plugin behaviour, I don't know what the added complexity within the engines plugin actually buys us.

    I'll probably remove code_paths; maybe someone can produce a patch + tests that implements them again in a working fashion, if there's enough demand.

    Apologise for the weak stance here - since code paths have been broken since 2.0, they should've been removed far earlier, rather than kept hanging round.

  • Nick Sutterer

    Nick Sutterer December 2nd, 2008 @ 08:51 AM

    argh... i was looking why #code_paths didn't work for the last 3 hrs.

    you mean we should add engines code_paths with

    ActiveSupport::Dependencies.load_paths << RAILS_ROOT+"/app/cells"


    cheers, nick

  • James Adam

    James Adam April 20th, 2009 @ 12:14 AM

    • State changed from “open” to “resolved”

    I've removed support for this in the edge branch. The simplest way to add your custom paths to the load path is, as you say, adding them to ActiveSupport::Dependencies.load_paths. This can be done quite simply in a plugin's init.rb file.

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 ยป

The rails engines plugin itself

Shared Ticket Bins

People watching this ticket