This project is archived and is in readonly mode.
uninitialized constant Rails::DeprecatedConstant::Rails (NameError)
Reported by Bharat Ruparel | August 29th, 2010 @ 02:17 AM
Just upgraded to Ruby 1.9.2-p0 and the latest Rails rc2. The app was running fine with ruby 1.9.2-head and Rails rc1. It will not start and gives the following error when I issue the command:
rails s
→ rails s
=> Booting WEBrick => Rails 3.0.0.rc2 application starting in
development on http://0.0.0.0:3000 => Call with -d to
detach => Ctrl-C to shutdown server Exiting
/home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in
const_missing_from_s3_library': uninitialized constant
Rails::DeprecatedConstant::Rails (NameError)
from (eval):1:in `block in initialize'
from /home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0.rc2/lib/rails/deprecation.rb:29:in `call'
from /home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0.rc2/lib/rails/deprecation.rb:29:in `method_missing'
from /home/bruparel/rr_work/file_manager/config/initializers/load_lib_dir.rb:1:in `<top (required)>'
from /home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0.rc2/lib/rails/engine.rb:201:in `block (2 levels) in <class:Engine>'
from /home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0.rc2/lib/rails/engine.rb:200:in `each'
from /home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0.rc2/lib/rails/engine.rb:200:in `block in <class:Engine>'
from /home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0.rc2/lib/rails/initializable.rb:25:in `instance_exec'
from /home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0.rc2/lib/rails/initializable.rb:25:in `run'
from /home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0.rc2/lib/rails/initializable.rb:50:in `block in run_initializers'
from /home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0.rc2/lib/rails/initializable.rb:49:in `each'
from /home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0.rc2/lib/rails/initializable.rb:49:in `run_initializers'
from /home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0.rc2/lib/rails/application.rb:134:in `initialize!'
from /home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0.rc2/lib/rails/application.rb:77:in `method_missing'
from /home/bruparel/rr_work/file_manager/config/environment.rb:5:in `<top (required)>'
from /home/bruparel/rr_work/file_manager/config.ru:3:in `block in <main>'
from /home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval'
from /home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize'
from /home/bruparel/rr_work/file_manager/config.ru:1:in `new'
from /home/bruparel/rr_work/file_manager/config.ru:1:in `<main>'
Do I need to regenrate the app with release candidate 2?
thanks.
Bharat
Comments and changes to this ticket
-
Bharat Ruparel August 29th, 2010 @ 02:42 AM
Please ignore if you think this is not important.
Here is what happened. My Rails 3 app in Release Candidate 1 with ruby 1.9.2-head from a month ago was working fine with the following initializer in config/initializers directory:
Dir.glob( "#{ RAILS_ROOT }/lib/*.rb" ).each { |f| require f }
After upgrading to Rails 3 Release candidate 2 with stable release of Ruby 1.9.2-p0, it won't start as I reported above. I changed the initializer code to read
Dir.glob( "#{ Rails.root }/lib/*.rb" ).each { |f| require f }
and it started fine and the tests pass.
I think we need to publish a warning that the "old" style constants will cause Release candidate 2 to not start?
Bharat
-
Rohit Arondekar August 29th, 2010 @ 12:41 PM
- State changed from new to needs-more-info
- Importance changed from to Low
Can you try using
Dir.glob( "#{ RAILS_ROOT }/lib/*.rb" ).each { |f| require f }
in a fresh RC 2 app? It didn't give any errors for me. I'm guessing this is an aws-s3-0.6.2 issue. But just to be sure can you check?
-
Bharat Ruparel August 29th, 2010 @ 03:07 PM
Hello Rohit,
The error is gone after I made the afore mentioned change. Rails 3 reandomly picks on aws-s3 or right_aws and reports the
uninitialized constant Rails::DeprecatedConstant::Rails (NameError)
error. I have googled around to find if there are any reported incidences of Rails 3 not playing well with these two gems but it is possible that I may have missed relevant information.
How do you suggest that I check aws?
Thanks.
Bharat -
Deleted User August 29th, 2010 @ 11:59 PM
I can confirm this error. Its actually two things having to do with RAILS_ROOT. From deprecation.rb line 48:
DeprecatedConstant.deprecate("RAILS_ROOT", "Rails.root.to_s")
First problem is when the proc on line 21 is called, it ends up as Rails::DeprecatedConstant::Rails which does not exist. So first change is:
DeprecatedConstant.deprecate("RAILS_ROOT", "::Rails.root.to_s")
Same would apply to the other deprecated constants.
Next the call to RAILS_ROOT call .to_path (at least from attachment fu, see attachment_fu.rb, line 4):
@@tempfile_path = File.join(RAILS_ROOT, 'tmp', 'attachment_fu')
Calling to_path on a string blows up. So these changes fix the problem for me:
DeprecatedConstant.deprecate("RAILS_ROOT", "::Rails.root") DeprecatedConstant.deprecate("RAILS_ENV", "::Rails.env") DeprecatedConstant.deprecate("RAILS_DEFAULT_LOGGER", "::Rails.logger")
-
Bharat Ruparel August 30th, 2010 @ 12:36 AM
If you folks need to look at a real app. I just uploaded both Rails 2.3.8 and Rails 3.0RC2 versions of my app on Github.
http://github.com/bruparel/file_manager238
http://github.com/bruparel/file_manager3
Bharat
-
Neeraj Singh August 30th, 2010 @ 01:50 AM
- State changed from needs-more-info to resolved
@cfis The changes suggested by you are already there.
DeprecatedConstant.deprecate("RAILS_ROOT", "::Rails.root.to_s") DeprecatedConstant.deprecate("RAILS_ENV", "::Rails.env") DeprecatedConstant.deprecate("RAILS_DEFAULT_LOGGER", "::Rails.logger")
-
Deleted User September 5th, 2010 @ 05:25 AM
Neeraj - I see that the :: as been added, so that is good.
But I was also saying this:
DeprecatedConstant.deprecate("RAILS_ROOT", "::Rails.root.to_s")
Should be this:
DeprecatedConstant.deprecate("RAILS_ROOT", "::Rails.root")
Notice the removal of "to_s"
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>