Nginx

Unicorn 顯示 Rack 錯誤未初始化常量 Rack::Lint::REQUEST_METHOD

  • April 14, 2015

我嘗試在 Ubuntu 14.04 上安裝 Unicorn + Nginx。每當站點被訪問時(通過 localhost:8080 或通過 Nginx),它只會返回一個空白的 500 錯誤。錯誤日誌給了我以下資訊:

NameError: uninitialized constant Rack::Lint::REQUEST_METHOD
   /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/lint.rb:298:in `check_env'
   /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/lint.rb:43:in `_call'
   /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/lint.rb:37:in `call'
   /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/showexceptions.rb:24:in `call'
   /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/commonlogger.rb:33:in `call'
   /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:218:in `call'
   /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/chunked.rb:54:in `call'
   /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/content_length.rb:15:in `call'
   /usr/lib/ruby/vendor_ruby/unicorn/http_server.rb:580:in `process_client'
   /usr/lib/ruby/vendor_ruby/unicorn/http_server.rb:660:in `worker_loop'
   /usr/lib/ruby/vendor_ruby/unicorn/http_server.rb:527:in `spawn_missing_workers'
   /usr/lib/ruby/vendor_ruby/unicorn/http_server.rb:153:in `start'
   /usr/bin/unicorn:126:in `<main>'
E, [2015-04-11T11:20:00.945818 #25817] ERROR -- : app error: uninitialized constant Rack::Request::SCRIPT_NAME (NameError)
E, [2015-04-11T11:20:00.945882 #25817] ERROR -- : /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/request.rb:21:in `script_name'
E, [2015-04-11T11:20:00.945904 #25817] ERROR -- : /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/showexceptions.rb:69:in `pretty'
E, [2015-04-11T11:20:00.945926 #25817] ERROR -- : /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/showexceptions.rb:33:in `rescue in call'
E, [2015-04-11T11:20:00.945946 #25817] ERROR -- : /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/showexceptions.rb:24:in `call'
E, [2015-04-11T11:20:00.945964 #25817] ERROR -- : /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/commonlogger.rb:33:in `call'
E, [2015-04-11T11:20:00.945984 #25817] ERROR -- : /var/lib/gems/1.9.1/gems/sinatra-1.4.6/lib/sinatra/base.rb:218:in `call'
E, [2015-04-11T11:20:00.946001 #25817] ERROR -- : /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/chunked.rb:54:in `call'
E, [2015-04-11T11:20:00.946018 #25817] ERROR -- : /var/lib/gems/1.9.1/gems/rack-1.6.0/lib/rack/content_length.rb:15:in `call'
E, [2015-04-11T11:20:00.946034 #25817] ERROR -- : /usr/lib/ruby/vendor_ruby/unicorn/http_server.rb:580:in `process_client'
E, [2015-04-11T11:20:00.946056 #25817] ERROR -- : /usr/lib/ruby/vendor_ruby/unicorn/http_server.rb:660:in `worker_loop'
E, [2015-04-11T11:20:00.946073 #25817] ERROR -- : /usr/lib/ruby/vendor_ruby/unicorn/http_server.rb:527:in `spawn_missing_workers'
E, [2015-04-11T11:20:00.946095 #25817] ERROR -- : /usr/lib/ruby/vendor_ruby/unicorn/http_server.rb:153:in `start'
E, [2015-04-11T11:20:00.946114 #25817] ERROR -- : /usr/bin/unicorn:126:in `<main>'

有任何想法嗎?

安裝的 unicorn 系統版本以及 gem 版本似乎是一個問題。修復我剛剛做的

apt-get remove unicorn
gem install unicorn

之後,問題就消失了

引用自:https://serverfault.com/questions/682012