tags:

views:

43

answers:

2

I'm on Ubuntu 10.10/Ruby 1.9.2

Whatever I do, I can't get a sinatra app to start on my local machine.

hello.rb:

require 'sinatra'
get '/' do
  "Hello World!"
end

"$ ruby hello.rb" and "$ ruby -rubygems hello.rb" both result in a new prompt with no action taken.

Any tips or pointers?

+6  A: 

This is a known issue in Sinatra 1.0 running on Ruby 1.9.2; it has been fixed in Sinatra 1.1 which is just around the corner.

Fix it with enable :run:

require 'sinatra'
enable :run

get '/' do
  "Hello World!"
end

Another issue you might run into with the Ruby 1.9.2 + Sinatra 1.0 stack concerns the change of the default load path for Ruby scripts in Ruby 1.9.2, which doesn't include the current directory, therefore views don't work as expected by default, fix it with:

set :views, File.dirname(FILE) + "/views"
Sirupsen
Thanks, that was it exactly.
Craig
+2  A: 

Upgrade to Sinatra 1.1.

Konstantin Haase