Welcome to Working With Rails

 

Discussion Forums

Discuss all things Ruby on Rails with perhaps the web's most vibrant group of Ruby on Rails enthusiasts.
cryptic "warning: already initialized constant" error
4 Posts
cryptic "warning: already initialized constant" error

From what I can tell, this error just means that you have some missing gems required somewhere in the application that are not being loaded but I've uninstalled gems and reinstalled them all again with no changes. I'm running Rails 2.3.2 on Ubuntu. Here is a gist of the full error log.

http://gist.github.com/86840

I've run the rake gems:install command as well as building them. I've gone through all the initializers and I can't find any gems or any libraries that are required that are not installed.

Any suggestions are appreciated. Thanks

On the prompt when you type gem list, can you see them?

It may also be due to your gempath which is not setup properly.

The paths to the gems were messed up and I fixed it by just using Ruby instead of Ruby enterprise. However I still get the error stating that "warning: already initialized constant". How else can I troubleshoot this? I've been pulling my hair out over this stupid error!

It looks like things are being loaded twice. Not sure what config/preinitializer.rb is (part of your own project?) but obviously rack shouldn't be loaded twice. This can happen if two things are requiring the same file in different ways - the only way that require protects you from multiple-loading is a string comparison of what was required. Eg. require 'redcloth' and require 'RedCloth' will both succeed.

The simplest way to resolve this is to edit the files that are being loaded, and at the very top of them (to debug) just put this:

y caller

Then just fire up your console, and you should get a stack trace of where the files are being loaded from. You might find multiple load points in your project, or at least some hints as to where to look for the double-loading.

4 Posts
Login to add your message