运行 Extreme Startup Sinatra Web 服务器时出错 [英] Error running Extreme Startup Sinatra web server

查看:28
本文介绍了运行 Extreme Startup Sinatra Web 服务器时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置和运行 Extreme Startup 在我的 Windows 机器上编写 Dojo.

I'm trying to set up and run the Extreme Startup coding dojo on my Windows machine.

当我尝试访问 http://localhost:3000 上的首页时,出现此错误:

When I try to access the front page on http://localhost:3000, I get this error:

application error
Errno::ENOENT at /
No such file or directory @ rb_sysopen - c:/Users/mark/Desktop/extreme_startup/lib/extreme_startup/views/leaderboard.haml
file: template.rb location: initialize line: 210
BACKTRACE
(expand)
JUMP TO: GET POST COOKIES ENV
c:/Users/mark/Desktop/extreme_startup/lib/extreme_startup/web_server.rb in block in <class:WebServer>
    set :players,    Hash.new
    set :players_threads, Hash.new
    set :scoreboard, Scoreboard.new(ENV['LENIENT'])
    set :question_factory, ENV['WARMUP'] ? WarmupQuestionFactory.new : QuestionFactory.new
    set :game_state, GameState.new

    get '/' do
      haml :leaderboard, :locals => {
          :leaderboard => LeaderBoard.new(scoreboard, players, game_state),
          :players => players  }
    end

    get '/scores' do
      LeaderBoard.new(scoreboard, players, game_state).to_json
    end
GET
No GET data.
POST
No POST data.
COOKIES
No cookie data.
Rack ENV
Variable    Value
GATEWAY_INTERFACE   
CGI/1.2
HTTP_ACCEPT 
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_ACCEPT_ENCODING    
gzip, deflate, sdch
HTTP_ACCEPT_LANGUAGE    
en-US,en;q=0.8,en-GB;q=0.6,da;q=0.4
HTTP_CACHE_CONTROL  
max-age=0
HTTP_CONNECTION 
keep-alive
HTTP_HOST   
localhost:3000
HTTP_UPGRADE_INSECURE_REQUESTS  
1
HTTP_USER_AGENT 
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36
HTTP_VERSION    
HTTP/1.1
PATH_INFO   
/
QUERY_STRING    
REMOTE_ADDR 
127.0.0.1
REQUEST_METHOD  
GET
REQUEST_PATH    
/
REQUEST_URI 
/
SCRIPT_NAME 
SERVER_NAME 
localhost
SERVER_PORT 
3000
SERVER_PROTOCOL 
HTTP/1.1
SERVER_SOFTWARE 
thin 1.6.3 codename Protein Powder
async.callback  
#<Method: Thin::Connection#post_process>
async.close 
#<EventMachine::DefaultDeferrable:0x00000004497b28>
rack.errors 
#<Object:0x000000031c5608>
rack.input  
#<StringIO:0x000000041a6860>
rack.logger 
#<Rack::NullLogger:0x0000000447cd28 @app=#<Rack::Protection::FrameOptions:0x0000000447ce40 @app=#<Rack::Protection::HttpOrigin:0x0000000447cee0 @app=#<Rack::Protection::IPSpoofing:0x0000000447cf80 @app=#<Rack::Protection::JsonCsrf:0x0000000447d020 @app=#<Rack::Protection::PathTraversal:0x0000000447d0c0 @app=#<Rack::Protection::XSSHeader:0x0000000447d1d8 @app=#<ExtremeStartup::WebServer:0x00000004497a88 @default_layout=:layout, @preferred_extension=nil, @app=nil, @template_cache=#<Tilt::Cache:0x00000004497a60 @cache={}>>, @options={:reaction=>:drop_session, :logging=>true, :message=>"Forbidden", :encryptor=>Digest::SHA1, :session_key=>"rack.session", :status=>403, :allow_empty_referrer=>true, :report_key=>"protection.failed", :html_types=>["text/html", "application/xhtml"], :xss_mode=>:block, :nosniff=>true, :except=>[:session_hijacking, :remote_token]}>, @options={:reaction=>:drop_session, :logging=>true, :message=>"Forbidden", :encryptor=>Digest::SHA1, :session_key=>"rack.session", :status=>403, :allow_empty_referrer=>true, :report_key=>"protection.failed", :html_types=>["text/html", "application/xhtml"], :except=>[:session_hijacking, :remote_token]}>, @options={:reaction=>:drop_session, :logging=>true, :message=>"Forbidden", :encryptor=>Digest::SHA1, :session_key=>"rack.session", :status=>403, :allow_empty_referrer=>true, :report_key=>"protection.failed", :html_types=>["text/html", "application/xhtml"], :except=>[:session_hijacking, :remote_token]}>, @options={:reaction=>:drop_session, :logging=>true, :message=>"Forbidden", :encryptor=>Digest::SHA1, :session_key=>"rack.session", :status=>403, :allow_empty_referrer=>true, :report_key=>"protection.failed", :html_types=>["text/html", "application/xhtml"], :except=>[:session_hijacking, :remote_token]}>, @options={:reaction=>:drop_session, :logging=>true, :message=>"Forbidden", :encryptor=>Digest::SHA1, :session_key=>"rack.session", :status=>403, :allow_empty_referrer=>true, :report_key=>"protection.failed", :html_types=>["text/html", "application/xhtml"], :except=>[:session_hijacking, :remote_token]}>, @options={:reaction=>:drop_session, :logging=>true, :message=>"Forbidden", :encryptor=>Digest::SHA1, :session_key=>"rack.session", :status=>403, :allow_empty_referrer=>true, :report_key=>"protection.failed", :html_types=>["text/html", "application/xhtml"], :frame_options=>:sameorigin, :except=>[:session_hijacking, :remote_token]}>>
rack.multiprocess   
false
rack.multithread    
true
rack.request.cookie_hash    
{}
rack.request.query_hash 
{}
rack.request.query_string   
rack.run_once   
false
rack.url_scheme 
http
rack.version    
[1, 0]
sinatra.accept  
[#<Sinatra::Request::AcceptEntry:0x0000000425ace8 @entry="text/html", @type="text/html", @params={}, @q=1.0>, #<Sinatra::Request::AcceptEntry:0x0000000425ab08 @entry="application/xhtml+xml", @type="application/xhtml+xml", @params={}, @q=1.0>, #<Sinatra::Request::AcceptEntry:0x0000000425a5b8 @entry="image/webp", @type="image/webp", @params={}, @q=1.0>, #<Sinatra::Request::AcceptEntry:0x0000000425a928 @entry="application/xml;q=0.9", @type="application/xml", @params={}, @q=0.9>, #<Sinatra::Request::AcceptEntry:0x0000000425a428 @entry="*/*;q=0.8", @type="*/*", @params={}, @q=0.8>]
sinatra.error   
#<Errno::ENOENT: No such file or directory @ rb_sysopen - c:/Users/mark/Desktop/extreme_startup/lib/extreme_startup/views/leaderboard.haml>
sinatra.route   
GET /
You're seeing this error because you have enabled the show_exceptions setting.

据我所知,有问题的代码行在第 28 行,这似乎是这个:

As far as I can tell, the offending line of code is on line 28, which seems to be this:

haml :leaderboard, :locals => {
    :leaderboard => LeaderBoard.new(scoreboard, players, game_state),
    :players => players  }

不幸的是,我对 Ruby 的了解几乎不存在,所以没有什么对我不利.

Unfortunately, my knowledge of Ruby is almost non-existent, so nothing there looks untoward to me.

当我启动 Web 服务器时,它会产生这个输出,包括一个警告,我(到目前为止没有成功)试图摆脱它.不知道有没有关系:

When I start the web server, it produces this output, including a single warning, that I (so far unsuccessfully) have tried to get rid of. I don't know if it's related:

$ ruby web_server.rb
:public is no longer used to avoid overloading Module#public, use :public_folder or :public_dir instead
        from c:/Users/mark/Desktop/extreme_startup/lib/extreme_startup/web_server.rb:20:in `<class:WebServer>'
== Sinatra (v1.4.6) has taken the stage on 3000 for development with backup from Thin
Thin web server (v1.6.3 codename Protein Powder)
Maximum connections set to 1024
Listening on localhost:3000, CTRL+C to stop

当我从 Chrome 向 http://localhost:3000 发出请求时,控制台输出以下错误消息:

When I issue the request to http://localhost:3000 from Chrome, the console outputs this error message:

WARN: tilt autoloading 'tilt/haml' in a non thread-safe way; explicit require 'tilt/haml' suggested.
2015-08-26 15:50:41 - Errno::ENOENT - No such file or directory @ rb_sysopen - c:/Users/mark/Desktop/extreme_startup/lib/extreme_startup/views/leaderboard.haml:
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/tilt-2.0.1/lib/tilt/template.rb:210:in `initialize'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/tilt-2.0.1/lib/tilt/template.rb:210:in `open'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/tilt-2.0.1/lib/tilt/template.rb:210:in `read_template_file'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/tilt-2.0.1/lib/tilt/template.rb:76:in `block in initialize'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/tilt-2.0.1/lib/tilt/template.rb:77:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/tilt-2.0.1/lib/tilt/template.rb:77:in `initialize'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:861:in `new'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:861:in `block in compile_template'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/tilt-2.0.1/lib/tilt.rb:88:in `fetch'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:840:in `compile_template'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:821:in `render'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:676:in `haml'
        c:/Users/mark/Desktop/extreme_startup/lib/extreme_startup/web_server.rb:28:in `block in <class:WebServer>'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1610:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1610:in `block in compile!'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:974:in `[]'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:974:in `block (3 levels) in route!'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:993:in `route_eval'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:974:in `block (2 levels) in route!'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1014:in `block in process_route'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1012:in `catch'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1012:in `process_route'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:972:in `block in route!'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:971:in `each'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:971:in `route!'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1084:in `block in dispatch!'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1066:in `block in invoke'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1066:in `catch'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1066:in `invoke'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1081:in `dispatch!'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:906:in `block in call!'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1066:in `block in invoke'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1066:in `catch'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1066:in `invoke'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:906:in `call!'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:894:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-protection-1.5.3/lib/rack/protection/xss_header.rb:18:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-protection-1.5.3/lib/rack/protection/path_traversal.rb:16:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-protection-1.5.3/lib/rack/protection/json_csrf.rb:18:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-protection-1.5.3/lib/rack/protection/base.rb:49:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-protection-1.5.3/lib/rack/protection/frame_options.rb:31:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/nulllogger.rb:9:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/rack-1.6.4/lib/rack/head.rb:13:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/show_exceptions.rb:21:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:181:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:2021:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1486:in `block in call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1795:in `synchronize'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/sinatra-1.4.6/lib/sinatra/base.rb:1486:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/connection.rb:86:in `block in pre_process'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/connection.rb:84:in `catch'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/thin-1.6.3/lib/thin/connection.rb:84:in `pre_process'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:1062:in `call'
        c:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:1062:in `block in spawn_threadpool'

出了什么问题,我该怎么做才能解决这个问题?

What's wrong, and what can I do to fix the issue?

我对 Ruby 几乎一无所知,所以这可能是一个愚蠢的初学者错误.

I know almost nothing about Ruby, so it's probably a stupid beginner's mistake.

推荐答案

您的问题是应用程序是很久以前开发的,没有人花时间升级.

Your problem is that the application was developed a long time ago an nobody took the time to upgrade.

例如,您应该使用 ruby​​ 1.9.3 运行它,它已终止运行.但是使用较新的 ruby​​ 版本可能会奏效.(至少 ruby​​-2.1.6 对我有用)

For example you should run it with ruby 1.9.3 which is end of live. But using a newer ruby version would probably work. (at least ruby-2.1.6 works for me)

但绝对行不通的是用 sinatra v1.4.6 运行这个项目.正如你在源代码中看到的,这个项目是用 v1.2.6<构建的/a>.可能您已经为其他项目安装了较新版本的 sinatra.所以我建议你在你的项目文件夹中安装 gems:

But what definitely not works is to run this project with sinatra v1.4.6. As you can see in the source code this project was build with v1.2.6. Probably you have installed a newer version of sinatra for a other project. So I would recommend that you install the gems in your project folder with:

捆绑安装 --binstubs --path vendor

bundle install --binstubs --path vendor

如果以这种方式安装,您可以拥有多个具有相同依赖项的项目而不会出现问题.但是现在您需要在命令前加上 bundle exec 前缀,例如 bundle exec ruby​​ web_server.rb.

If installed this way you can have multiple projects with the same dependency with out a problem. But now you need to prefix you commands with bundle exec for example bundle exec ruby web_server.rb.

或者,如果您使用的是 rvm,则有一个名为 gemsets 的东西,它执行类似的操作.

Or if you are using rvm there is this thing called gemsets which does something similar.

这篇关于运行 Extreme Startup Sinatra Web 服务器时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆