Well, I'm trying to run a simple web server through "rack". So this is my program:
require 'rubygems'
require 'rack'
class HelloWorld
def call(env)
[200, {"Content-Type" => "text/html"}, ["Hello Rack!"]]
end
end
Rack::Handler::Mongrel.run HelloWorld.new, :Port => 9292
If I run it in the console, it works fine. If I run it in Eclipse, it ends up with error:
/Users/MY_SUPER_SECRET_USER/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- rack (LoadError)
from /Users/MY_SUPER_SECRET_USER/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/MY_SUPER_SECRET_USER/Sites/service/service.rb:2:in `<main>'
The one that is working is called like this:
MY_SUPER_SECRET_USER@MacBook-Pro:~/Sites/service $ which ruby
/Users/MY_SUPER_SECRET_USER/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
MY_SUPER_SECRET_USER@MacBook-Pro:~/Sites/service $ ruby service.rb
Then when I try to open localhost:9292
it shows the expected "Hello Rack" code.
I'm on Mac OS X 10.8, with ruby 1.9.3 installed through rvm (this must be obvious). My "rack" package has been installed with sudo gem install rack
So as you can see, the Eclipse is configured with the very same ruby executable. Any suggestions will be of great help!