Bizarre Rails problem
Tuesday, January 16th, 2007Something in changeset r5951 caused my RoR project to break under Linux in subtle ways. I get the following error when starting the console:
Loading development environment.
/usr/lib/ruby/1.8/date/format.rb:593:TypeError: superclass mismatch for class DateTime
./script/../config/../config/../vendor/rails/railties/lib/dispatcher.rb:90:NoMethodError: undefined method `attr_accessor_with_default’ for #<Class:Dispatcher>
./script/../config/../config/../app/controllers/application.rb:3:NameError: uninitialized constant ActionController
I can reproduce this problem with a fresh copy of Rails:
# cd /tmp
# rails rails
# cd rails
# script/console # this works
# rake rails:freeze:edge
# script/console # this fails
Using svn:externals on an existing project, I have tracked the problem down to the file vendor/rails/activesupport/lib/active_support/core_ext/date_time.rb. It opens the DateTime class like this:
class DateTime
include ActiveSupport::CoreExtensions::Time::Behavior
end
And in so doing, provokes the error. It actually doesn’t matter what, if anything, is done with the DateTime class. Simply reopening it provokes the failure.
Interestingly, my existing projects continue to work fine as long as they reside in the /home hierarchy (which happens to be on a separate filesystem).
But if the project (new or existing) is in any other directory, I get the error.
Debug Info: Prior to freezing to Edge, script/about shows this:
[cch1@bmw script]$ ./about
About your application’s environment
Ruby version 1.8.5 (i386-linux)
RubyGems version 0.9.0
Rails version 1.1.6
Active Record version 1.14.4
Action Pack version 1.12.5
Action Web Service version 1.1.6
Action Mailer version 1.2.5
Active Support version 1.3.1
Application root /tmp/rails
Environment development
Database adapter mysql
[cch1@bmw script]$
NB: The problem also happens with RubyGems 0.8.11.
I have raised case 7094 on the RoR developer site.