Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when starting Sinatra: "tried to create Proc object without a block"

Tags:

ruby

sinatra

I am very new to ruby / rails and have an issue that I have not been able to figure out but feel it should be relatively simple to fix.

Command:

ruby app.rb

Error:

/Library/Ruby/Gems/1.8/gems/sinatra-1.2.5/lib/sinatra/base.rb:1144:in `define_method': tried to create Proc object without a block (ArgumentError)
    from /Library/Ruby/Gems/1.8/gems/sinatra-1.2.5/lib/sinatra/base.rb:1144:in `compile!'
    from /Library/Ruby/Gems/1.8/gems/sinatra-1.2.5/lib/sinatra/base.rb:1129:in `route'
    from /Library/Ruby/Gems/1.8/gems/sinatra-1.2.5/lib/sinatra/base.rb:1111:in `get'
    from /Library/Ruby/Gems/1.8/gems/sinatra-1.2.5/lib/sinatra/base.rb:1474:in `send'
    from /Library/Ruby/Gems/1.8/gems/sinatra-1.2.5/lib/sinatra/base.rb:1474:in `get'
    from app.rb:4

app.rb contents:

require 'rubygems'
require 'sinatra'

get '/' do
  "Hello World"
end

I have updated all gems and still get the same error. I can post list of gems as well if need.

like image 707
jeffreynolte Avatar asked Sep 16 '25 18:09

jeffreynolte


1 Answers

From what I can tell, and I've encountered this before, v1.2.5 of Sinatra is the problem. v1.2.3 doesn't do it, so try

gem install sinatra -v 1.2.3

to install the previous version, then add:

gem 'sinatra', '=1.2.3'

before the require statement.

This is documented as an issue.


EDIT: Sinatra just bumped to a new version, 1.2.6, which fixes this problem. Use gem update sinatra, followed by gem uninstall sinatra -v 1.2.5 to remove the old, buggy, version.

like image 196
the Tin Man Avatar answered Sep 18 '25 10:09

the Tin Man