Sinatra:使用捆绑包执行红宝石app.rb时,未定义的方法“运行” [英] Sinatra: Undefined method 'run' when using bundle exec ruby app.rb
本文介绍了Sinatra:使用捆绑包执行红宝石app.rb时,未定义的方法“运行”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有模块化样式的sinatra应用程序,其末尾有以下行,因此可以独立运行:
I have modular style sinatra app, with the following line near the end, so that it can be run standalone:
# ... all code before this omitted
run! if __FILE__ == $0
end
# This is the end of the file
当我使用 ruby app.rb
运行此应用程序时,它运行正常,并且webrick启动。
When I run this app with ruby app.rb
it works fine, and webrick starts up.
但是,如果我改为使用 bundle exec ruby app.rb
运行它,则会收到此错误:
However, if I run it instead with bundle exec ruby app.rb
I get this error:
>bundle exec ruby app.rb
C:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.4/lib/sinatra/base.rb:1488:in `start_server': undefined method `run' for HTTP:Module (NoMethodError)
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/sinatra-1.4.4/lib/sinatra/base.rb:1426:in `run!'
什么原因导致此错误?
推荐答案
明确设置您的Web服务器,例如
Explicitly set your webserver, e.g.
set :server, 'thin'
,并确保添加要使用的任何服务器您的 Gemfile
,例如
and make sure you add whatever server you’re using to your Gemfile
, e.g.
gem 'thin'
这篇关于Sinatra:使用捆绑包执行红宝石app.rb时,未定义的方法“运行”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文