This project is archived and is in readonly mode.
unnecessarily loading environment
Reported by Steven Soroka | December 9th, 2008 @ 07:39 PM | in 2.x
misc.rake in task :environment often unneccessarily loads the environment after it's already been loaded. This causes most rake tasks to run quite a bit slower.
The solution: require environment unless defined?(Rails)
Comments and changes to this ticket
-
Steven Soroka January 9th, 2009 @ 10:48 PM
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 January 12th, 2009 @ 05:33 AM
I can't seem to confirm this.
I generated a fresh Rails app from
rails/master
(at296ca4da1700eb27a7043112d22027444ea0e548
), and vendor'd rails. I stuck aputs
inenvironment.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
require
is that it'll only load a file once...Kernel#load
is 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 January 12th, 2009 @ 02:54 PM
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 January 12th, 2009 @ 04:27 PM
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 March 12th, 2009 @ 05:24 PM
- State changed from new to invalid
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>