Trying to teach myself Ruby (again)

Now that I have a real web project to work on I figured it’s a good time to try and teach myself Ruby again. Sinatra seems to be the new hotness so that’s what I’m trying, but so far things aren’t going quite as I expected. Everything appears to be installed, but when I run the “Hello, World!” script, the webserver doesn’t start as it’s apparently supposed to do:

[evan@ehoffman 16:59:34 ~]$ ruby --version
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-linux]
[evan@ehoffman 16:59:39 ~]$ irb
irb(main):001:0> require 'sinatra'
=> true
irb(main):002:0>
You have new mail in /var/spool/mail/evan
[evan@ehoffman 17:00:20 ~]$ cat hi.rb
#require 'rubygems'
require 'sinatra'

get '/' do
	"Hello World"
end
[evan@ehoffman 17:00:24 ~]$ ruby hi.rb
[evan@ehoffman 17:00:33 ~]$

I’ve tried this on two different systems with the same result. I’ve seen this same sample code in 20 different places, including sinatrarb.com, but for some reason it’s not working for me. Rather than firing up a webserver on port 4567, running “ruby hi.rb” simply exits immediately.

Edit: According to a post on comp.lang.ruby entitled 1.9.2-rc2 -> 1.9.2-p0 breaks Sinatra, server.rb needs to be edited:

Sinatra’s behaviour has appeared to change in the 1.9 compatible
versions.
I need to add the following line in my server.rb:
set :run, true

I’m debating whether it’s worth doing this (I have 8 different server.rbs in my /usr dir) or just reinstalling an older version of ruby that doesn’t have this issue.

Edit 2: Resolved by installing Ruby 1.9.2-rc2.

Advertisements

2 Replies to “Trying to teach myself Ruby (again)”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s