This project is archived and is in readonly mode.
unnecessarily loading environment
-
Steven Soroka
I found this by putting print "loading environment" at the top of config/environment.rb
Wondering if anyone can confirm that rake tasks are loading the environment multiple times.
-
Chris Kampmeier
I can't seem to confirm this.
I generated a fresh Rails app from
rails/master(at296ca4da1700eb27a7043112d22027444ea0e548), and vendor'd rails. I stuck aputsinenvironment.rb, and all rake tasks that required the environment only seemed to print it once:chrisk@al3:~/Documents/railstest/testapp $ rake db:version (in /Users/chrisk/Documents/railstest/testapp) *** initializing Rails Current version: 0 chrisk@al3:~/Documents/railstest/testapp $Also, the whole point of
requireis that it'll only load a file once...Kernel#loadis the one that mindlessly loads things again when you specify it twice.So, can you post a step-by-step process to reproduce? We must be doing something different.
Thanks!
-
Steven Soroka
require will load the same library twice if you provide a different path to the same file, eg, require 'config/environment' and require "#{RAILS_ROOT}/config/environment"
Though I duplicated your setup with a fresh install and couldn't replicate the problem. I'll try to isolate it in my project and see what's happening.
-
Steven Soroka
I found an environment require in a task I didn't need, and the rest of the duplicate loads are related to rspec, so I'll just close this ticket.
-
Pratik
- State changed from new to invalid
