I’m interested in running Discourse with Ruby 3.
I’d like to know how to address Job exception: wrong number of arguments (given 4, expected 3)
with Ruby 3.
- Steps to reproduce
$ ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
$ bundle install
$ bundle exec rake db:create
$ bundle exec rake db:migrate
$ RAILS_ENV=test bundle exec rake db:create db:migrate
$ bundle exec rails server
-
Expected behavior
It should run without exceptions. -
Actual behavior
It raisesJob exception: wrong number of arguments (given 4, expected 3)
.
... snip ...
2021-09-21T13:55:20.993Z pid=319230 tid=6jdi WARN: {"current_db":"default","current_hostname":"localhost","message":"While ticking scheduling manager"}
2021-09-21T13:55:20.993Z pid=319230 tid=6jdi WARN: ArgumentError: wrong number of arguments (given 4, expected 3)
2021-09-21T13:55:20.993Z pid=319230 tid=6jdi WARN: /home/yahonda/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/redis-4.4.0/lib/redis.rb:1784:in `zrange'
/home/yahonda/src/github.com/discourse/discourse/lib/discourse_redis.rb:59:in `public_send'
/home/yahonda/src/github.com/discourse/discourse/lib/discourse_redis.rb:59:in `block (3 levels) in <class:DiscourseRedis>'
/home/yahonda/src/github.com/discourse/discourse/lib/discourse_redis.rb:29:in `ignore_readonly'
/home/yahonda/src/github.com/discourse/discourse/lib/discourse_redis.rb:59:in `block (2 levels) in <class:DiscourseRedis>'
/home/yahonda/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/mini_scheduler-0.13.0/lib/mini_scheduler/manager.rb:279:in `schedule_next_job'
/home/yahonda/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/mini_scheduler-0.13.0/lib/mini_scheduler/manager.rb:273:in `block in tick'
/home/yahonda/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/mini_scheduler-0.13.0/lib/mini_scheduler/manager.rb:323:in `block in lock'
/home/yahonda/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/mini_scheduler-0.13.0/lib/mini_scheduler/distributed_mutex.rb:46:in `synchronize'
/home/yahonda/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/mini_scheduler-0.13.0/lib/mini_scheduler/distributed_mutex.rb:14:in `synchronize'
/home/yahonda/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/mini_scheduler-0.13.0/lib/mini_scheduler/manager.rb:322:in `lock'
/home/yahonda/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/mini_scheduler-0.13.0/lib/mini_scheduler/manager.rb:272:in `tick'
/home/yahonda/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/mini_scheduler-0.13.0/lib/mini_scheduler.rb:71:in `block (2 levels) in start'
Job exception: wrong number of arguments (given 4, expected 3)
- Minimum cases
def zrange(key, start, stop, withscores: false, with_scores: withscores)
end
zrange("default:_scheduler_queue_default_", 0, 0, {:withscores=>true})
- Ruby 3.0.2
$ ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux]
$ irb
irb(main):001:1* def zrange(key, start, stop, withscores: false, with_scores: withscores)
irb(main):002:0> end
=> :zrange
irb(main):003:0>
irb(main):004:0> zrange("default:_scheduler_queue_default_", 0, 0, {:withscores=>true})
(irb):1:in `zrange': wrong number of arguments (given 4, expected 3) (ArgumentError)
from (irb):4:in `<main>'
from /home/yahonda/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.3.7/exe/irb:11:in `<top (required)>'
from /home/yahonda/.rbenv/versions/3.0.2/bin/irb:23:in `load'
from /home/yahonda/.rbenv/versions/3.0.2/bin/irb:23:in `<main>'
irb(main):005:0>
- Ruby 2.7.4
% ruby -v
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-darwin21]
yahonda@mymacbookpro redis-rb % irb tags/v4.4.0
irb(main):001:0> ekey, start, stop, withscores: false, with_scores: withscores)
end
irb(main):001:1* def zrange(key, start, stop, withscores: false, with_scores: withscores)
irb(main):002:0> end
=> :zrange
irb(main):003:0>
irb(main):004:0> zrange("default:_scheduler_queue_default_", 0, 0, {:withscores=>true})
=> nil
irb(main):005:0>