Sinatra app - Shotgun不工作 - "无法加载这样的文件 - rack / commonlogger(LoadError)"

时间:2016-09-03 13:14:30

标签: sinatra rack shotgun

当我尝试用Shotgun启动我的Sinatra-app时,我看到LoadError:

E-MBP:test_app admin$ shotgun app.rb
/Users/admin/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require': cannot load such file -- rack/commonlogger (LoadError)
from /Users/admin/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
from /Users/admin/.rvm/rubies/ruby-2.3.1/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
from /Users/admin/.rvm/gems/ruby-2.3.1/gems/shotgun-0.9.1/bin/shotgun:112:in `<top (required)>'
from /Users/admin/.rvm/gems/ruby-2.3.1/bin/shotgun:23:in `load'
from /Users/admin/.rvm/gems/ruby-2.3.1/bin/shotgun:23:in `<main>'
from /Users/admin/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
from /Users/admin/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'

之前没有错误!

&#34; ruby​​ app.rb&#34;仍然有效,我在浏览器中看到了我的主页:

E-MBP:test_app admin$ ruby app.rb
== Sinatra (v1.4.7) has taken the stage on 4567 for development with backup from Thin
Thin web server (v1.7.0 codename Dunder Mifflin)
Maximum connections set to 1024
Listening on localhost:4567, CTRL+C to stop

我该如何解决这个问题?

E-MBP:test_app admin$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
E-MBP:test_app admin$ rvm -v
rvm 1.27.0 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

Sinatra文件夹只包含一个文件 - test_app / app.rb:

require 'sinatra'

get '/' do
  "Hello!"
end

Gems rake / shotgun / sinatra是最新的:

E-MBP:test_app admin$ gem update rake
Updating installed gems
Nothing to update
E-MBP:test_app admin$ gem update shotgun
Updating installed gems
Nothing to update
E-MBP:test_app admin$ gem update sinatra
Updating installed gems
Nothing to update

1 个答案:

答案 0 :(得分:1)

我遇到了同样的错误,通过将gem 'shotgun'添加到我的项目的Gemfile并找到捆绑我找到了错误。