You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
incombatible with Ruby-3 / later gem versions (wrong number of arguments) #285
just to make the report reproducible, I'm using a docker file. This dockerfile works (with ruby-2.7):
FROM ruby:2-alpine
RUN apk add --update --upgrade --no-cache --virtual .build-dependencies gcc musl-dev make sqlite-dev &&
gem install gemstash &&
apk del .build-dependencies &&
rm -rf /var/cache/apk/*
CMD ["gemstash","start","--no-daemonize"]
But when replacing the FROM image with ruby:alpine (i.e. using ruby 3) it still compiles,yet the process results in
/usr/local/bundle/gems/gemstash-2.1.0/lib/gemstash/web.rb:10:in initialize': wrong number of arguments (given 1, expected 0) (ArgumentError) from /usr/local/bundle/gems/sinatra-2.1.0/lib/sinatra/base.rb:1527:in new'
[...]
The reason of bundle _1.17.3_ add psych -v '~> 3.0' --skip-install is taht gemstash is not compatible with psych >=4, see #297 for more detail. cc @hsbt
output:
Starting gemstash! [212/1693]
[2021-06-03 05:12:36 +0000] - INFO - [573] Puma starting in cluster mode...
[2021-06-03 05:12:36 +0000] - INFO - [573] * Version 4.3.8 (ruby 3.0.1-p64), codename: Mysterious Traveller
[2021-06-03 05:12:36 +0000] - INFO - [573] * Min threads: 0, max threads: 16
[2021-06-03 05:12:36 +0000] - INFO - [573] * Environment: development
[2021-06-03 05:12:36 +0000] - INFO - [573] * Process workers: 1
[2021-06-03 05:12:36 +0000] - INFO - [573] * Phased restart available
[2021-06-03 05:12:36 +0000] - INFO - [573] * Listening on tcp://0.0.0.0:9292
[2021-06-03 05:12:36 +0000] - INFO - [573] Use Ctrl-C to stop
/src/lib/gemstash/web.rb:10:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError)
from /usr/local/bundle/gems/sinatra-2.1.0/lib/sinatra/base.rb:1527:in `new'
from /usr/local/bundle/gems/sinatra-2.1.0/lib/sinatra/base.rb:1527:in `new'
from /src/lib/gemstash/config.ru:14:in `block in <main>'
from /usr/local/bundle/gems/rack-2.2.3/lib/rack/builder.rb:116:in `eval'
from /usr/local/bundle/gems/rack-2.2.3/lib/rack/builder.rb:116:in `new_from_string'
from /usr/local/bundle/gems/rack-2.2.3/lib/rack/builder.rb:105:in `load_file'
from /usr/local/bundle/gems/rack-2.2.3/lib/rack/builder.rb:66:in `parse_file'
from /usr/local/bundle/gems/puma-4.3.8/lib/puma/configuration.rb:321:in `load_rackup'
from /usr/local/bundle/gems/puma-4.3.8/lib/puma/configuration.rb:246:in `app'
from /usr/local/bundle/gems/puma-4.3.8/lib/puma/runner.rb:165:in `app'
from /usr/local/bundle/gems/puma-4.3.8/lib/puma/runner.rb:172:in `start_server'
from /usr/local/bundle/gems/puma-4.3.8/lib/puma/cluster.rb:269:in `worker'
from /usr/local/bundle/gems/puma-4.3.8/lib/puma/cluster.rb:138:in `block (2 levels) in spawn_workers'
from /usr/local/bundle/gems/puma-4.3.8/lib/puma/cluster.rb:138:in `fork'
from /usr/local/bundle/gems/puma-4.3.8/lib/puma/cluster.rb:138:in `block in spawn_workers'
from /usr/local/bundle/gems/puma-4.3.8/lib/puma/cluster.rb:134:in `times'
from /usr/local/bundle/gems/puma-4.3.8/lib/puma/cluster.rb:134:in `spawn_workers'
from /usr/local/bundle/gems/puma-4.3.8/lib/puma/cluster.rb:469:in `run'
from /usr/local/bundle/gems/puma-4.3.8/lib/puma/launcher.rb:172:in `run'
from /usr/local/bundle/gems/puma-4.3.8/lib/puma/cli.rb:80:in `run'
from /src/lib/gemstash/cli/start.rb:16:in `run'
from /src/lib/gemstash/cli.rb:79:in `start'
from /usr/local/bundle/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
from /usr/local/bundle/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
from /usr/local/bundle/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
from /usr/local/bundle/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
from /src/lib/gemstash/cli.rb:34:in `start'
from bin/gemstash:4:in `<main>'
One workaround is to give up keyword arguments.
I made the changes by the following diff and it eventually works in Ruby 3.
Should we make that move, using that change, and add Ruby 3 to the build matrix?
I don't know if we should. We don't even know when Sinatra would fully support Ruby 3. Besides, this might also be a breaking change depends on whether we consider Gemstash::Web as an internal class or not.
I have another proposal, maybe we can make it compatible by supporting both sequence arguments and keyword arguments.
Activity
tonytonyjan commentedon Jun 3, 2021
It's one of breaking changes in Ruby 3.
https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
tonytonyjan commentedon Jun 3, 2021
to reproduce this issue:
The reason of
bundle _1.17.3_ add psych -v '~> 3.0' --skip-installis tahtgemstashis not compatible with psych >=4, see #297 for more detail. cc @hsbtoutput:
tonytonyjan commentedon Jun 3, 2021
After some investigation, I think it should be an upstream issue sinatra/sinatra#1701
kyrofa commentedon Aug 18, 2021
I just ran into this. Looks like that upstream issue is fixed, is there anything we should do in gemstash?
hadmut commentedon Nov 6, 2021
What version do you run?
I just tried gemstash in docker ruby:3-alpine with ruby 3.0.2-p107, puma 4.3.10 and gemstash 2.1.0 and still do get
/usr/local/bundle/gems/gemstash-2.1.0/lib/gemstash/web.rb:10:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError)
tonytonyjan commentedon Nov 6, 2021
Sorry, my bad. It's false positive because I mis-configured the gemstash.
This is still an upstream issue: sinatra/sinatra#1531 (comment)
tonytonyjan commentedon Nov 6, 2021
One workaround is to give up keyword arguments.
I made the changes by the following diff and it eventually works in Ruby 3.
olleolleolle commentedon Nov 9, 2021
Should we make that move, using that change, and add Ruby 3 to the build matrix?
tonytonyjan commentedon Nov 9, 2021
I don't know if we should. We don't even know when Sinatra would fully support Ruby 3. Besides, this might also be a breaking change depends on whether we consider
Gemstash::Webas an internal class or not.I have another proposal, maybe we can make it compatible by supporting both sequence arguments and keyword arguments.
Just like how ERB and Psych do:
If we don't think it's a breaking change, then I think applying the change I showed above would be OK.
olleolleolle commentedon Nov 9, 2021
@tonytonyjan Even better!
tonytonyjan commentedon Nov 9, 2021
I can help make the PR if this is the conclusion :)
feat: support Ruby 3
feat: support Ruby 3
feat: support Ruby 3
tonytonyjan commentedon Nov 10, 2021
@olleolleolle Yet another solution that I found is also good:
So that we don't need to change the caller and they can still use keyword arguments:
tonytonyjan commentedon Nov 10, 2021
To be clearer, here are 2 options, both of them passes CI tests:
Option 1 - support both sequence arguments and keyword arguments:
It modifies 4 files:
lib/gemstash/config.rulib/gemstash/web.rbspec/gemstash/web_spec.rbspec/support/test_gemstash_server.rudiff
Option 2 - Use
ruby2_keywordsIt modifies 1 files:
lib/gemstash/web.rbdiff
tonytonyjan commentedon Nov 11, 2021
@olleolleolle any thought about how to support Ruby 3?
olleolleolle commentedon Nov 11, 2021
@tonytonyjan My take: This repo is an appplication, so it's fair to depend on and use ruby2_keywords.
feat: support Ruby 3
feat: support Ruby 3 (#312)