Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #10376 (new defect)

Opened 9 months ago

Last modified 9 months ago

No longer seeing MissingSourceFile exceptions bubbled up to script/server

Reported by: igotimac Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveSupport Version: edge
Severity: normal Keywords:
Cc:

Description

The problem seems to be related to installing rails 1.99, because I never had this problem before doing so. But, the problem appears even when I set my RAILS_GEM_VERSION back to '1.2.2'

Interestingly, if I set it all the way back to 1.1.6 I do again see the right exception.

Here's the exception I'm getting right now with anything from 1.2.2 to 1.2.5:

/usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:196:in `activate': can't activate rails (= 1.99.0), already activated rails-1.2.3] (Gem::Exception)
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:32:in `require'
        from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require'
        from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in `new_constants_in'
        from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require'
        from /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39
        from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
        from script/server:3

And, the reason I'm getting this is because I am requiring a file that does not exist. The problem of course is that this stack trace gives me no clue as to that being the problem.

If I remove the bad require, the complaint about loading 1.99 is suddenly gone.

I've taken to manually editing active support dependencies.rb so I can find out about potential causes of this, since rails is no longer telling me.

Just to solve the problem for myself, I've mucked with dependencies.rb

class Object
  ...

  def require(file, *extras)
    Dependencies.new_constants_in(Object) { super(file, *extras) }
  rescue Exception => exception  # errors from required file
    puts exception.inspect
    exception.blame_file! file
    raise
  end

adding a little puts statement so I have some idea when this happens.

Clearly this is not the correct solution.

How in the world is it that 1.99 has modified the way that older version of rails are loading dependencies for me?

So, some even more confusing information.

When I bump up to 1.99 and I have an erroneous require I get absolutely ZERO output, I just get "Exiting" and then the process ends.

I tested this on another machine and got ENTIRELY DIFFERENT stack traces, but still, the wrong output!

when running 1.99

/Library/Ruby/Gems/1.8/gems/rails-1.99.0/lib/commands/servers/mongrel.rb:16: warning: already initialized constant OPTIONS
/Library/Ruby/Gems/1.8/gems/rails-1.99.0/lib/commands/servers/mongrel.rb:19: undefined method `options' for []:Array (NoMethodError)
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:32:in `gem_original_require'
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:32:in `require'
	from /Library/Ruby/Gems/1.8/gems/activesupport-1.99.0/lib/active_support/dependencies.rb:496:in `require'
	from /Library/Ruby/Gems/1.8/gems/activesupport-1.99.0/lib/active_support/dependencies.rb:342:in `new_constants_in'
	from /Library/Ruby/Gems/1.8/gems/activesupport-1.99.0/lib/active_support/dependencies.rb:496:in `require'
	from /Library/Ruby/Gems/1.8/gems/rails-1.99.0/lib/commands/server.rb:39
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require'
	from script/server:3

when running 1.2.3

/Library/Ruby/Gems/1.8/gems/rails-1.2.3/lib/initializer.rb:328:in `send': undefined method `session=' for ActionController::Base:Class (NoMethodError)
	from /Library/Ruby/Gems/1.8/gems/rails-1.2.3/lib/initializer.rb:328:in `initialize_framework_settings'
	from /Library/Ruby/Gems/1.8/gems/rails-1.2.3/lib/initializer.rb:327:in `each'
	from /Library/Ruby/Gems/1.8/gems/rails-1.2.3/lib/initializer.rb:327:in `initialize_framework_settings'
	from /Library/Ruby/Gems/1.8/gems/rails-1.2.3/lib/initializer.rb:324:in `each'
	from /Library/Ruby/Gems/1.8/gems/rails-1.2.3/lib/initializer.rb:324:in `initialize_framework_settings'
	from /Library/Ruby/Gems/1.8/gems/rails-1.2.3/lib/initializer.rb:96:in `process'
	from /Library/Ruby/Gems/1.8/gems/rails-1.2.3/lib/initializer.rb:43:in `send'
	from /Library/Ruby/Gems/1.8/gems/rails-1.2.3/lib/initializer.rb:43:in `run'
	 ... 27 levels...
	from /Library/Ruby/Gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `require'
	from script/server:3

what could be going on?

All of these stack traces are caused by requiring something non-existant, and they go away if I remove that require or satisfy it. Why is this happening? Why am I not seeing MissingSourceFile exceptions?

Change History

12/05/07 16:11:03 changed by igotimac

It seems this is caused by the require being in or being triggered by the loading of environment.rb

http://www.dansketcher.com/2007/05/07/warning-already-initialized-constant-options/

12/05/07 16:15:04 changed by igotimac

It appears this guy got one of the stack traces listed in this bug because rails couldn't load the missing constant RAILS_GEM_VERSION http://www.ruby-forum.com/topic/131210