This project is archived and is in readonly mode.

#6545 open
Elias Baixas

in versions 2.3.X Configuration/Initialization problem when using config/environments/{xxx}.rb and config.plugins

Reported by Elias Baixas | March 8th, 2011 @ 05:54 PM

in rails-2.3.11/lib/rails/plugin/loader.rb method "plugins", the instance variable @plugins is cached (@plugins||= ...)

this method (plugins) is called from within the add_plugin_load_paths as seen in this backtrace:

"/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/rails/plugin/loader.rb:24:in plugins'", "/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/rails/plugin/loader.rb:56:inadd_plugin_load_paths'", "/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/initializer.rb:294:in add_plugin_load_paths'", "/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/initializer.rb:136:inprocess'", "/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/initializer.rb:113:in send'", "/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.11/lib/initializer.rb:113:inrun'", "/Users/elias/src/ruby/prueba/config/environment.rb:23",

since "add_plugin_load_paths" is called before "load_environment" in Rails::Initializer.process:

def process
  Rails.configuration = configuration

  check_ruby_version
  install_gem_spec_stubs
  set_load_path
  add_gem_load_paths

  require_frameworks
  set_autoload_paths
  add_plugin_load_paths
  load_environment

if one is to configure plugin loading order, and maybe prevention of plugin load, the caching of @plugins before "load_environment" renders config.plugins useless if they were set in config/environments/{production,development,test}.rb.

this renders all the config.plugins functionality useless, since (in my POV) the main use of config.plugins is to enable or disable some plugins in Production or Development.

This would be fixed just by moving load_environment before add_plugin_load_paths in Rails::Initializer.process.

to reproduce this issue, just do (with rails 2.3.X with X upto 11):

rails prueba
cd prueba
script/plugin install git://github.com/abedra/safe-erb
echo "config.plugins=[]" >> config/environments/production.rb
echo "config.plugins=[:"safe-erb"] >> config/environments/development.rb
script/generate scaffold post body:text title:string
RAILS_ENV=production rake db:migrate
RAILS_ENV=development rake db:migrate

now

RAILS_ENV=production script/server

and navigate to localhost:3000/posts and see how the plugin was loaded (since safe-erb prevented outputting some strings)

then

RAILS_ENV=production script/console

Rails.configuration.plugins shows []

but it is wrong, since the plugin was actually loaded.

Comments and changes to this ticket

Create your profile

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

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages