# \`bundle exec rails server\` raises \`Job exception: wrong number of arguments (given 4, expected 3)\` with Ruby 3.0.2

**URL:** https://meta.discourse.org/t/bundle-exec-rails-server-raises-job-exception-wrong-number-of-arguments-given-4-expected-3-with-ruby-3-0-2/204105
**Category:** Development
**Created:** [September 21, 2021, 2:13pm UTC](https://meta.discourse.org/t/bundle-exec-rails-server-raises-job-exception-wrong-number-of-arguments-given-4-expected-3-with-ruby-3-0-2/204105 "2021-09-21T14:13:26Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![yahonda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yahonda/32/234118_2.png) [@yahonda](https://meta.discourse.org/u/yahonda)
#### Post date: [September 21, 2021, 2:13pm UTC](https://meta.discourse.org/t/bundle-exec-rails-server-raises-job-exception-wrong-number-of-arguments-given-4-expected-3-with-ruby-3-0-2/204105/1 "2021-09-21T14:13:26Z")

</div>

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

```plaintext
$ 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 raises `Job exception: wrong number of arguments (given 4, expected 3)`.

```plaintext
... 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

```plaintext
def zrange(key, start, stop, withscores: false, with_scores: withscores)
end

zrange("default:_scheduler_queue_default_", 0, 0, {:withscores=>true})

```

- Ruby 3.0.2

```plaintext
$ 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

```plaintext
% 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>

```

---

<div class="post-metadata">

### Author: ![yahonda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yahonda/32/234118_2.png) [@yahonda](https://meta.discourse.org/u/yahonda)
#### Post date: [September 21, 2021, 11:09pm UTC](https://meta.discourse.org/t/bundle-exec-rails-server-raises-job-exception-wrong-number-of-arguments-given-4-expected-3-with-ruby-3-0-2/204105/2 "2021-09-21T23:09:24Z")

</div>

A workaround should be like adding \*\* to the last hash as follows.

```plaintext
irb(main):001:1* def zrange(key, start, stop, withscores: false, with_scores: withscores)
irb(main):002:0> end
=> :zrange
irb(main):003: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):3:in `<main>'
	from /Users/yahonda/.rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/irb-1.3.7/exe/irb:11:in `<top (required)>'
	from /Users/yahonda/.rbenv/versions/3.0.2/bin/irb:23:in `load'
	from /Users/yahonda/.rbenv/versions/3.0.2/bin/irb:23:in `<main>'
irb(main):004:0> zrange("default:_scheduler_queue_default_", 0, 0, **{:withscores=>true})
=> nil
irb(main):005:0>

```

---

<div class="post-metadata">

### Author: ![yahonda](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yahonda/32/234118_2.png) [@yahonda](https://meta.discourse.org/u/yahonda)
#### Post date: [September 27, 2021, 7:50am UTC](https://meta.discourse.org/t/bundle-exec-rails-server-raises-job-exception-wrong-number-of-arguments-given-4-expected-3-with-ruby-3-0-2/204105/3 "2021-09-27T07:50:13Z")

</div>

I have created a pull request to address it. [FIX: Address ArgumentError: wrong number of arguments (given 4, expected 3) by yahonda · Pull Request #14444 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/14444)
