6

Trying out Sinatra on Windows

Posted November 9th, 2007 in General, Linux, Microsoft, Open Source, Web Design, ruby by ryan

I saw a lot of buzz about the new Sinatra web framework and decided I’d give it a try. I have a client now that has a simple site they need up now and then I can migrate them to Rails over time. When I saw how easy Sinatra looked, I thought I could give it a chance to see what it could do.

I installed Sinatra via RubyGems:
gem install sinatra -y

After that I created a simple file following the example:

require 'rubygems'
require 'sinatra'


get '/' do
"Now we're cooking with gas"
end

But much to my dismay, nothing happened when running this on my windows box. I instantly searched Google for “Sinatra on windows” and found the Google Group for Sinatra and a post explaining that Sinatra doesn’t run on Windows yet. As I read into the thread, I found someone had some suggestions for making it work.

John Bledsoe had the following suggestions:

My humble suggestion would be to remove the FileUtils#touch from
Sinatra::Server#tail and update Environment#prepare_loggers to
something like:

def prepare_loggers(logger = nil)
if logger.nil?
FileUtils.touch(Options.log_file)
logger = Logger.new(open(Options.log_file, 'w')
end
end

Making these changes allowed Sinatra to run, but it wouldn’t server the page. Instead it returned an error:

Fri Nov 09 16:26:26 -0800 2007: ERROR: undefined method `info’ for nil:NilClass

I made a post to the group and was promptly replied to! The general advice given is that it is a rapidly emerging framework undergoing a lot of changes and to check back soon.

More on testing Sinatra in Linux coming soon….

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

6 Responses so far.

  1. [...] Computerworld Breaking News wrote an interesting post today onHere’s a quick excerptMore on testing Sinatra in Linux coming soon……. [...]

  2. andreas says:

    I had success with out commenting line 12 in /lib/sinatra/server.rb – then Sinatra will actually serve pages.

  3. Ryan says:

    When I comment out line 12 in server.rb, I get the following error when executing my app:

    c:/ruby/lib/ruby/1.8/fileutils.rb:1029:in `utime’: Permission denied – ./develop
    ment.log (Errno::EACCES)
    from c:/ruby/lib/ruby/1.8/fileutils.rb:1029:in `touch’
    from c:/ruby/lib/ruby/1.8/fileutils.rb:1026:in `each’
    from c:/ruby/lib/ruby/1.8/fileutils.rb:1026:in `touch’
    from c:/ruby/lib/ruby/gems/1.8/gems/sinatra-0.1.7/lib/sinatra/environmen
    t.rb:12:in `prepare_loggers’
    from c:/ruby/lib/ruby/gems/1.8/gems/sinatra-0.1.7/lib/sinatra.rb:46
    from app.rb:5

  4. Ryan says:

    Ok…so I reinstalled the gem to get rid of my previous changes and start over fresh and then I commented out line 12 of server.rb and now it’s working!

    Thanks!

  5. A quick update for those seeing this now for the first time. Sinatra 0.2.2 is out and has fixed this problem along with many others. Logging is now only given to STDOUT and there are no more log files to maintain. If you have any questions please see us in IRC (irc.freenode.net #sinatra) or groups.google.com/group/sinatrarb

    -Blake

  6. Ryan says:

    Thanks for the update Blake!

Leave a Reply





FireStats icon Powered by FireStats