UPDATE:
I found the simple answer and it’s completely my own fault: I stored the above code in a file called “eventmachine.rb”. Thus when I required ‘eventmachine’ it just imported the same file, which does not contain a definition for EventMachine.
So this is not really a post about EventMachine.
ORIGINAL POST:
Excuse me, but what’s going on?
require 'rubygems'
require 'eventmachine'
EventMachine
gives
uninitialized constant EventMachine
in both TextMate and on the console when I run “ruby myfile.rb”.
But if I type the same thing into IRB, I get
=> EventMachine
.
…
I got so frustrated that I followed the rash instructions on http://blog.carlmercier.com/2007/12/14/how-to-fix-that-rubygems-mess-on-leopard/ — wiping out my Ruby and Rubygems environments and reinstalling them from MacPorts. IRB still works and TextMate/commandline still fails in the same way. I even reduced my TextMate PATH to the one place where Ruby, Gem, and IRB are installed now: /opt/local/bin — which is what Which reports.
Finally, when I
puts Gem.path
on either IRB, TextMate, or the console, I get the same path.
I found the simple answer and it’s completely my own fault:
I stored the above code in a file called “eventmachine.rb”. Thus when I required ‘eventmachine’ it just imported the same file, which does not contain a definition for EventMachine.