开发者

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

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"
e开发者_JS百科nd

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜