Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected error while processing request: uninitialized constant Rack::Request::Helpers::HTTP_HOST #1143

Closed
hadmut opened this issue Feb 6, 2017 · 2 comments

Comments

@hadmut
Copy link

hadmut commented Feb 6, 2017

Hi,

I just tried the simple sinatra example of running

require 'sinatra'

get '/' do
'Hello world!'
end

(based on rack) and ran into

% ruby sitest.rb
/var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/show_exceptions.rb:16: warning: already initialized constant Rack::ShowExceptions::CONTEXT
/usr/lib/ruby/vendor_ruby/rack/showexceptions.rb:16: warning: previous definition of CONTEXT was here
/var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/show_exceptions.rb:114: warning: already initialized constant Rack::ShowExceptions::TEMPLATE
/usr/lib/ruby/vendor_ruby/rack/showexceptions.rb:115: warning: previous definition of TEMPLATE was here
== Sinatra (v1.4.7) has taken the stage on 4567 for development with backup from Thin
Thin web server (v1.6.3 codename Protein Powder)
Maximum connections set to 1024
Listening on localhost:4567, CTRL+C to stop
Unexpected error while processing request: uninitialized constant Rack::Request::Helpers::HTTP_HOST
/var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/request.rb:229:in host_with_port' /var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/request.rb:235:in host'
(erb):124:in pretty' /usr/lib/ruby/2.3.0/erb.rb:864:in eval'
/usr/lib/ruby/2.3.0/erb.rb:864:in result' /var/lib/gems/2.3.0/gems/rack-2.0.1/lib/rack/show_exceptions.rb:96:in pretty'
/usr/lib/ruby/vendor_ruby/sinatra/show_exceptions.rb:34:in rescue in call' /usr/lib/ruby/vendor_ruby/sinatra/show_exceptions.rb:25:in call'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:182:in call' /usr/lib/ruby/vendor_ruby/sinatra/base.rb:2013:in call'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:1487:in block in call' /usr/lib/ruby/vendor_ruby/sinatra/base.rb:1787:in synchronize'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:1487:in call' /usr/lib/ruby/vendor_ruby/thin/connection.rb:86:in block in pre_process'
/usr/lib/ruby/vendor_ruby/thin/connection.rb:84:in catch' /usr/lib/ruby/vendor_ruby/thin/connection.rb:84:in pre_process'
/usr/lib/ruby/vendor_ruby/eventmachine.rb:1054:in call' /usr/lib/ruby/vendor_ruby/eventmachine.rb:1054:in block in spawn_threadpool'

Has trouble finding the definition of HTTP_HOST

@PingLord
Copy link

Same here

Listening on 0.0.0.0:8003, CTRL+C to stop
Unexpected error while processing request: uninitialized constant Rack::Request::Helpers::HTTP_HOST
/home/user/.gem/ruby/2.3.0/gems/rack-2.0.1/lib/rack/request.rb:229:in host_with_port' /home/user/.gem/ruby/2.3.0/gems/rack-2.0.1/lib/rack/request.rb:235:in host'
(erb):124:in pretty' /usr/lib/ruby/2.3.0/erb.rb:864:in eval'
/usr/lib/ruby/2.3.0/erb.rb:864:in result' /home/sebastian/.gem/ruby/2.3.0/gems/rack-2.0.1/lib/rack/show_exceptions.rb:96:in pretty'
/usr/lib/ruby/vendor_ruby/sinatra/show_exceptions.rb:34:in rescue in call' /usr/lib/ruby/vendor_ruby/sinatra/show_exceptions.rb:25:in call'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:182:in call' /usr/lib/ruby/vendor_ruby/sinatra/base.rb:2013:in call'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:1487:in block in call' /usr/lib/ruby/vendor_ruby/sinatra/base.rb:1787:in synchronize'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:1487:in call' /usr/lib/ruby/vendor_ruby/thin/connection.rb:86:in block in pre_process'
/usr/lib/ruby/vendor_ruby/thin/connection.rb:84:in catch' /usr/lib/ruby/vendor_ruby/thin/connection.rb:84:in pre_process'
/usr/lib/ruby/vendor_ruby/eventmachine.rb:1054:in call' /usr/lib/ruby/vendor_ruby/eventmachine.rb:1054:in block in spawn_threadpool'

The code :

require 'sinatra'

set :bind, '0.0.0.0'
set :port, 8003


get '/' do

  erb :get_users
end

get_users.erb templace is empty.

@jeremyevans
Copy link
Contributor

Rack::HTTP_HOST has been set since 131d9fd. Constant lookup of HTTP_HOST inside Rack::Request::Helpers#host_with_port should find Rack::HTTP_HOST. I'm not sure if this is an issue with an old version of Sinatra, or related to Thin, but it doesn't appear to be a problem with Rack itself. If you still believe this is a problem with Rack itself, please submit a failing test or self-contained example showing the problem, without using any other libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants