Setting up my new computer now that I am settled in in London was turning out to be a right pain. I had ruby, rails, and postgresql installed, but my application was not starting.
I was getting the following error:
=> Booting Mongrel (use 'script/server webrick' to force WEBrick) => Rails application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server ** Starting Mongrel listening at 0.0.0.0:3000 ** Starting Rails with development environment... Exiting /opt/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/mongrel.rb:15: warning: already initialized constant OPTIONS /opt/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/mongrel.rb:18: undefined method `options' for []:Array (NoMethodError) from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:32:in `gem_original_require' from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:32:in `require' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in `new_constants_in' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require' from /opt/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:39 from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require' from /opt/local/lib/ruby/vendor_ruby/1.8/rubygems/custom_require.rb:27:in `require' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in `new_constants_in' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:495:in `require' from script/server:3
and lots more similar ones. I tried uninstalling Mongrel, reactivating old versions of rails, and so on. Nothing worked. A fresh rails application started ok though Searching online revealed nothing either, until I came upon a post about a gem not working on win32, and the solution was to remove that gem.
Ahhhhh.
I was missing gems. I installed every one that I had on my lappy, and everthing was cheerful again. Strange that the error message (even under webrick) did not report the problem clearly. In any case, problem resolved.
11 replies on “warning: already initialized constant OPTIONS”
What gem was it?
There were heaps: log4r, calibre, sentry… I’m not sure which one it was exactly, but it was definitely a missing dependency issue
Apparently, this happens if you require any non-existing file from within config/environment.rb
After switching my rails app to another server, I was getting that cryptic error message when I ran script/server. Turns out I had a “require ‘json'” in environment.rb, but didn’t have the json gem installed.
It’s not necessarily related to missing gems, it can be easily reproduced if you “require ‘nonexistingfile'”.
OK sorted this one out.
The solution for me was installing the ruby-debug gem – sudo gem install ruby-debug
The reason: /config/environments/development.rb requires it.
begin
require ‘ruby-debug’
rescue
config.breakpoint_server = true
end
Thanks! It helps me :)
I’ve missed rmagic on my Debian box.
aptitude install librmagick-ruby
What a horribly vague error message. I fixed the problem as well. I had done a little “tidying” of my code and accidentally removed my own library that I was “requiring.” It would be nice if we could be told the name of the missing resource (or at least that there was a missing resource.)
Had the same problem.
A tip is to start webrick instead.
At least it will tell you which gem that it fails to load ;)
ruby script/server webrick
Like:
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’: no such file to load — GD (MissingSourceFile)
hey thanks for the post and the comments. this error message sucks, indeed.
That’s not the only error that can crop up from requiring a non-existant file.
It seems like a bug to me, What should really happen is a MissingSourceFile exception, which I actually see if I downgrade to rails 1.1.6
here are some other strange exceptions/behavior I’ve seen, all caused by requiring a missing file or gem:
http://dev.rubyonrails.org/ticket/10376
Hai,
i am new to Rails, i am struggling with the same above problem .so can any body give me detailed explanation how to solve this problem. i didnt understand what u r saying, so any body help me please. almost it sucks 2 days..
Thanks,
Muni.
Apparently it also happens if you accidentally have a circular include. The weird thing is I thought there was a different error message for circular requires, but I wasn’t getting it, just the “warning: already initialized constant” thing. But when I tracked down and removed the circular require it fixed it.