Sinatra在服务器上安装时会出现以下错误

时间:2011-12-03 21:13:33

标签: ruby-on-rails ruby gem sinatra rack

我尝试使用rack& amp;来安装一个简单的hello world脚本。屈

到目前为止,我已经在localhost上完成了所有工作,但是当我尝试上传到我的服务器时,通过ssh运行时出现以下错误:

rackup config.ru

它真的只显示什么都没有'。我必须按^ + C才能中止。我试过了

rackup config.ru --debug

我明白了:

nil
Exception `LoadError' at /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36 - no such file to load -- sinatra
Exception `LoadError' at /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36 - no such file to load -- Win32API
Exception `LoadError' at /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:62 - no such file to load -- Win32API
Exception `LoadError' at /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36 - no such file to load -- mongrel
Exception `NoMethodError' at /usr/lib/ruby/1.8/rational.rb:78 - undefined method `gcd' for Rational(1, 2):Rational
Exception `LoadError' at /usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/lib/mongrel/gems.rb:7 - no such file to load -- mongrel_experimental
Exception `Gem::LoadError' at /usr/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:247 - Could not find mongrel_experimental (>= 1.1.5) amongst [actionmailer-3.1.3, actionpack-3.1.3, activemodel-3.1.3, activerecord-3.1.3, activeresource-3.1.3, activesupport-3.1.3, arel-2.2.1, builder-3.0.0, bundler-1.0.21, cgi_multipart_eof_fix-2.5.0, coffee-rails-3.1.1, coffee-script-2.2.0, coffee-script-source-1.1.3, daemons-1.1.0, erubis-2.7.0, eventmachine-0.12.10, execjs-1.2.9, fastthread-1.0.7, gem_plugin-0.2.3, hike-1.2.1, i18n-0.6.0, jquery-rails-1.0.19, json-1.6.3, mail-2.3.0, mime-types-1.17.2, mongrel-1.1.5, multi_json-1.0.4, polyglot-0.3.3, rack-1.3.5, rack-cache-1.1, rack-mount-0.8.3, rack-protection-1.1.4, rack-ssl-1.3.2, rack-test-0.6.1, rails-3.1.3, railties-3.1.3, rake-0.9.2.2, rdoc-3.11, rockhands-0.0.6, rubygems-update-1.8.12, sass-3.1.11, sass-rails-3.1.5, sinatra-1.3.1, sprockets-2.0.3, thin-1.3.1, thor-0.14.6, tilt-1.3.3, treetop-1.4.10, tzinfo-0.3.31]
#<Rack::ContentLength:0x2b1ed5eebe88
 @app=
  #<Rack::Chunked:0x2b1ed5eebed8
   @app=
    #<Rack::CommonLogger:0x2b1ed5eec130
     @app=
      #<Rack::ShowExceptions:0x2b1ed490bd70
       @app=
        #<Rack::Lint:0x2b1ed490bdc0
         @app=Sinatra::Application,
         @content_length=nil>,
       @template=
        #<ERB:0x2b1ed490bd20
         @filename=nil,
         @safe_level=nil,
         @src=ALL MY HTML IS HERE

如果这有帮助:

*本地宝石*

actionmailer (3.1.3)
actionpack (3.1.3)
activemodel (3.1.3)
activerecord (3.1.3)
activeresource (3.1.3)
activesupport (3.1.3)
arel (2.2.1)
builder (3.0.0)
bundler (1.0.21)
cgi_multipart_eof_fix (2.5.0)
coffee-rails (3.1.1)
coffee-script (2.2.0)
coffee-script-source (1.1.3)
daemons (1.1.0)
erubis (2.7.0)
eventmachine (0.12.10)
execjs (1.2.9)
fastthread (1.0.7)
gem_plugin (0.2.3)
hike (1.2.1)
i18n (0.6.0)
jquery-rails (1.0.19)
json (1.6.3)
mail (2.3.0)
mime-types (1.17.2)
mongrel (1.1.5)
multi_json (1.0.4)
polyglot (0.3.3)
rack (1.3.5)
rack-cache (1.1)
rack-mount (0.8.3)
rack-protection (1.1.4)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.1.3)
railties (3.1.3)
rake (0.9.2.2)
rdoc (3.11)
rockhands (0.0.6)
rubygems-update (1.8.12)
sass (3.1.11)
sass-rails (3.1.5)
sinatra (1.3.1)
sprockets (2.0.3)
thin (1.3.1)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.31)

ruby 1.8.7 (2009-06-08 patchlevel 173) [x86_64-linux]

2 个答案:

答案 0 :(得分:0)

mongrel实验不是一个单独的宝石吗?您的堆栈跟踪指的是第7行和第7行。 8,但它没有在你当地的宝石中列出。试试gem install mongrel_experimental

答案 1 :(得分:0)

你确定应用程序无法运行吗? 对我来说,rackup默认情况下也是静默的,但应用程序在端口9292上运行正常。

使用最简单的Rack应用程序进行本地测试:

# config.ru

run lambda { |env|
  [
    200, 
    { 'Content-Type'  => 'text/plain' },
    "Hello World"
  ]
}

哦,添加--debug也会显示与您相同的异常,但应用运行正常。

我相信您的应用程序实际上正在运行,但由于某种原因您无法访问它。也许端口9292无法远程访问。

在远程计算机上尝试telnet localhost 9292以验证应用是否正常工作。你应该看到:

~$ telnet localhost 9292
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.