1. Computing
Michael Morin

Sinatra Not Working on 1.9.2?

By September 8, 2010

Follow me on:

Sinatra 1.0, a micro-web framework, is having a bit of trouble with Ruby 1.9.2.  Your apps just won't run, you get no output and the interpreter returns to the shell with no exceptions thrown.  This (presumably) will be fixed in the next version of Sinatra, but there's a temporary workaround, and it only requires you to add a single line to your application.  The line is highlighted below.


#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'

enable :run

get '/' do
  "Hello, world!"
end
Comments
September 27, 2010 at 3:34 pm
(1) John says:

Thanks! That was a real head scratcher there….glad I’m not the only one that ran into this.

October 2, 2010 at 5:28 am
(2) Anurag Priyam says:

I had some problems with rendering erb templates from ‘./views’.
This is the error I get:
Errno::ENOENT: No such file or directory – /home/yeban/code/Sinatra/simpleSequenceSearchServer/<internal:lib/rubygems/views/search.erb

Any clue?

October 4, 2010 at 11:54 am
(3) Ryan says:

You have to define the views path like

LOCAL_PATH = File.dirname(__FILE__);
set :views, LOCAL_PATH + ‘/views’

or something like that

October 20, 2010 at 3:39 am
(4) Konstantin Haase says:

Just use Sinatra 1.1.a:

gem install sinatra –pre

October 20, 2010 at 4:47 am
(5) ruby says:

That’s a good tip Konstantin, however it all depends on how your Sinatra apps are deployed. That’s only useful if your server has the pre-release gem.

January 6, 2011 at 1:11 am
(6) hbdev says:

I added “enable :run” line in .rb file
and getting this error while running application –

undefined method `enable’ for main:Object (NoMethodError)

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

©2014 About.com. All rights reserved.