Ruby Sinatra Hello World Error in `remove_const

2019-05-06 13:12发布

问题:

Just trying to get simple http server running and have no clue about ruby

/usr/local/lib/ruby/gems/1.9.1/gems/rack-1.3.5/lib/rack/backports/uri/common_192.rb:53:in `remove_const': constant URI::WFKV_ not defined (NameError)
    from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.3.5/lib/rack/backports/uri/common_192.rb:53:in `<module:URI>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.3.5/lib/rack/backports/uri/common_192.rb:19:in `<top (required)>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.3.5/lib/rack/utils.rb:12:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.3.5/lib/rack/utils.rb:12:in `<top (required)>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.3.5/lib/rack/request.rb:1:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.3.5/lib/rack/request.rb:1:in `<top (required)>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.3.5/lib/rack/showexceptions.rb:3:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.3.5/lib/rack/showexceptions.rb:3:in `<top (required)>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.3.1/lib/sinatra/showexceptions.rb:1:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.3.1/lib/sinatra/showexceptions.rb:1:in `<top (required)>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.3.1/lib/sinatra/base.rb:12:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.3.1/lib/sinatra/base.rb:12:in `<top (required)>'
    from /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.3.1/lib/sinatra.rb:4:in `require'
    from /usr/local/lib/ruby/gems/1.9.1/gems/sinatra-1.3.1/lib/sinatra.rb:4:in `<top (required)>'
    from http.rb:1:in `require'
    from http.rb:1:in `<main>'

and here is my version of ruby on centos ruby 1.9.1p376 (2009-12-07 revision 26041) [x86_64-linux]

any help would be very appreciated

回答1:

That's known issue specific for ruby-1.9.1 and rake-1.3.5. Please look at this. What about updating ruby for 1.9.2 or 1.9.3 version?

UPDATE

On the one hand, WFKV_ constant was absent in ruby 1.9.1 version and appears in 1.9.2 version. On the other hand, this constant is defined in rack's uri/common_192.rb file. 2011-10-03 Ben Hamill fixed issue #246 'Silence the warning about redefining this constant from the standard library' through addition remove_const :WFKV_ line of code and this fix was included in rack-1.3.5 version. Therefore, if you use 1.9.1 version, you have to use rack-1.3.4.



标签: ruby sinatra