Sinatra:使用bundle exec ruby app.rb时未定义的方法’run’
我有模块化风格的sinatra应用程序,接近结尾的以下行,以便它可以独立运行:
# ... all code before this omitted run! if __FILE__ == $0 end # This is the end of the file
当我用ruby app.rb
运行这个应用程序时,它工作正常,webrick启动。
但是,如果我使用bundle exec ruby app.rb
运行它,我会收到此错误:
>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!'
是什么导致了这个错误?
明确设置您的网络服务器,例如
set :server, 'thin'
并确保将您正在使用的任何服务器添加到您的Gemfile
,例如
gem 'thin'