I'm trying to start Shotgun for a Sinatra app after having upgraded to Ruby 3.0.1, and get this:
$ shotgun
== Shotgun/Thin on http://127.0.0.1:9393/
/Users/me/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/rack-2.2.3/lib/rack/handler/thin.rb:11:in `run': wrong number of arguments (given 2, expected 1) (ArgumentError)
from /Users/me/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/shotgun-0.9.2/bin/shotgun:156:in `<top (required)>'
from /Users/me/.rbenv/versions/3.0.1/bin/shotgun:23:in `load'
from /Users/me/.rbenv/versions/3.0.1/bin/shotgun:23:in `<main>'
Running gem list
, I get:
shotgun (0.9.2)
What's going on? Thanks!
Ruby v3.0 introduces a breaking change, relating to keyword vs positional arguments.
The shotgun
gem hasn't been updated for a long time; the latest version (0.9.2) was released in September 2016.
Looking at the gem in github, I see there's an open issue about this exact problem you've raised, and someone has already - helpfully - forked the project with a fix.
Unless the original author merges this fix and releases a new version of the gem, you'll need to use a forked version such as the above. For example, update your Gemfile
to say:
gem 'shotgun', git: 'https://github.com/delonnewman/shotgun.git'
And then run bundle install
.
There's also this open PR with the exact same fix, so you could equally use that fork instead.
... Or alternatively, stick to ruby 2.7
for now.