From: Dan Teitsort Date: 2008-01-11T10:45:52+09:00 Subject: Re: Singleton initilized twice maikonaraujo@gmail.com wrote: > > Tks, I was doing a hello worl only ehehe, and runing "ruby script/ > server" on the prompt. Then it sounds like you still have the problem. I've noticed the exact same condition -- a singleton getting initialized twice -- and have found a solution that works for me. (Sorry this is 10 months late, but maybe it will help someone.) I'm using 1.8.6-p36 on Windows. In my case, the issue seemed related to the fact that 'require' behaves badly if you happen to include the same file multiple times using different path specifications (e.g., relative vs. absolute vs. yet-another-relative). In those cases, the code in the file being 'required' gets executed each time a 'new' path formulation is used, even though the same physical file is being referenced. I addressed this by being careful to always File.expand_path(...) on the path before doing a 'require', e.g., require File.expand_path('../../some_file_with_a_singleton_class.rb') instead of require '../../some_file_with_a_singleton_class.rb' I should that, in my case, there was a _chance_ the multiple requires were being done on different threads. But, offhand, I don't think they were. So, I guess the moral is: Singleton users, beware the require 'relative_path' -- Posted via http://www.ruby-forum.com/.