tilemaker icon indicating copy to clipboard operation
tilemaker copied to clipboard

server.rb - Recent version of `rack` doesn't work. 2.2 does work.

Open orblivion opened this issue 3 years ago • 3 comments

I got this error when trying to run the server.

$ ruby server.rb ~/countries-raster.mbtiles 
Starting local server
Traceback (most recent call last):
        3: from server.rb:22:in `<main>'
        2: from server.rb:118:in `<class:MapServer>'
        1: from /usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require'
/usr/lib/ruby/vendor_ruby/rubygems/core_ext/kernel_require.rb:85:in `require': cannot load such file -- rack/handler (LoadError)

I'm not a Ruby guy so I got help with this on Stack Overflow: https://stackoverflow.com/a/75100160/475877

Solutions:

  • gem 'rack', '~> 2.2' fixes it - at least the server runs, no comment yet on how well it works
  • Install rackup instead of holding back rack to 2.2 - I see a subsequent error instead (uninitialized constant Rackup::Handler::WEBrick (NameError)

I'll leave it you to decide which route to take; perhaps you'd prefer the latter, including fixing the subsequent error, so that rack is up to date.

There's also the side suggestion of using Gemfile/bundle. Perhaps you'd want to consider that as well as you address the rest of this.

orblivion avatar Jan 12 '23 17:01 orblivion

Changing the "require" to

require 'rackup'

and the call to

Rackup::Handler::WEBrick.run(app)

also works (in that it doesn't crash), but I can't test it further here until https://github.com/systemed/tilemaker/issues/391 is resolved .

SomeoneElseOSM avatar Jan 15 '23 00:01 SomeoneElseOSM

@SomeoneElseOSM to avoid warnings and possibly issues with older versions (which currently this library relies on based on this issue). I would propose:

if Rack::VERSION > '3.0'
  require 'rackup'
  require 'rack/handler'
end

engineersmnky avatar Jan 19 '23 03:01 engineersmnky

@orblivion Latest change make it only support rack v3 now: #460

typebrook avatar Mar 08 '23 01:03 typebrook