Search code examples
rubyopenstreetmaprackmbtiles

`require': cannot load such file -- rack/handler (LoadError)


I'm not a Ruby person, so this may be a 101 question. I'm just trying to use a utility that happens to be written in Ruby.

I'm using tilemaker, a utility in the openstreetmap ecosystem. It creates tiles in the mbtiles format. The repository comes with a simple utility to serve the tiles on a browser to test the files you create. This utility is written in Ruby, and is what I'm having trouble with.

The repo's README has instructions for the server utility. The installation instructions read:

(If you don't already have them, you'll need to install Ruby and the required gems to run the demonstration server. On Ubuntu, for example, sudo apt install sqlite3 libsqlite3-dev ruby ruby-dev and then sudo gem install sqlite3 cgi glug rack.)

I'm on Debian 11 (on Qubes, so I don't mind running sudo gem install as they recommend). I hope this is close enough to Ubuntu but maybe this is related to the problem.

This is what I get:

$ 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)

What am I missing here? Thanks.


Solution

  • It appears that the issue is that you are using a 3.X release of rack.

    According to the CHANGELOG as of version 3.0 Rack::Handler was removed from rack and pulled out into its own gem (rackup).

    To resolve the issue you will need to either use an older version of rack

    gem 'rack', '~> 2.2' 
    

    Or you will need to add the rackup gem as a dependency:

    gem 'rack'
    gem 'rackup' 
    

    Either option will provide access to rack/handler: