简体   繁体   English

运行Extreme Startup Sinatra Web服务器时出错

[英]Error running Extreme Startup Sinatra web server

I'm trying to set up and run the Extreme Startup coding dojo on my Windows machine. 我正在尝试在Windows计算机上设置并运行Extreme Startup编码dojo。

When I try to access the front page on http://localhost:3000 , I get this error: 当我尝试访问http:// localhost:3000的首页时 ,出现此错误:

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.

As far as I can tell, the offending line of code is on line 28, which seems to be this : 据我所知,令人反感的代码行在第28行, 这似乎是这样的

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

Unfortunately, my knowledge of Ruby is almost non-existent, so nothing there looks untoward to me. 不幸的是,我对Ruby的了解几乎不存在,所以对我来说没有什么不好的。

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. 当我启动Web服务器时,它会产生此输出,包括一个警告,表明我(到目前为止没有成功)已尝试摆脱该警告。 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

When I issue the request to http://localhost:3000 from Chrome, the console outputs this error message: 当我从Chrome向http:// localhost:3000发出请求时,控制台会输出以下错误消息:

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? 有什么问题,我该怎么解决?

I know almost nothing about Ruby, so it's probably a stupid beginner's mistake. 我对Ruby几乎一无所知,所以这可能是一个愚蠢的初学者的错误。

Your problem is that the application was developed a long time ago an nobody took the time to upgrade. 您的问题是该应用程序是很久以前开发的,没有人花时间升级。

For example you should run it with ruby 1.9.3 which is end of live. 例如,您应该使用已结束的ruby 1.9.3运行它。 But using a newer ruby version would probably work. 但是使用更新的红宝石版本可能会起作用。 (at least ruby-2.1.6 works for me) (至少ruby-2.1.6对我有用)

But what definitely not works is to run this project with sinatra v1.4.6. 但是,绝对不可行的是使用sinatra v1.4.6运行该项目。 As you can see in the source code this project was build with v1.2.6 . 正如您在源代码中看到的那样,该项目是使用v1.2.6构建的。 Probably you have installed a newer version of sinatra for a other project. 可能您已为其他项目安装了较新版本的sinatra。 So I would recommend that you install the gems in your project folder with: 因此,我建议您使用以下命令在项目文件夹中安装gems:

bundle install --binstubs --path vendor 捆绑安装--binstubs --path供应商

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 . 但是现在您需要在命令之前加上bundle exec前缀,例如bundle exec ruby web_server.rb

Or if you are using rvm there is this thing called gemsets which does something similar. 或者,如果您使用的是rvm ,那么有个叫gemsets的东西可以做类似的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM