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

瘦欲@ 提交于 2019-12-31 01:44:06

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/5845278/error-when-starting-sinatra-tried-to-create-proc-object-without-a-block

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!