Skip to content
Latchkey

ArgumentError: wrong number of arguments in CI

A method received a different number of arguments than its definition accepts. In CI this commonly appears after a dependency upgrade changed a method signature that your code still calls the old way.

What this error means

A test or boot fails with ArgumentError stating given vs expected counts. The call site looks correct against the version you remember but not against the version installed on the runner.

ruby
ArgumentError:
       wrong number of arguments (given 2, expected 1)
     # ./app/services/notifier.rb:21:in `deliver'

Diagnose it: Ruby version and platform

Bundler resolves against the Ruby version and the platform recorded in the lockfile. A runner on a different Ruby or a Linux platform missing from Gemfile.lock fails in a way that names a gem rather than the cause.

Terminal
ruby -v && bundle -v
cat .ruby-version 2>/dev/null
bundle platform

# the usual CI-only failure: Linux platform absent from the lockfile
bundle lock --add-platform x86_64-linux
bundle install --jobs 4 --retry 3

Common causes

Gem signature changed

An upgraded gem changed a method to take keyword arguments or fewer positional ones, but your call still passes the old positional list.

Keyword vs positional in Ruby 3

Ruby 3 separates keyword and positional arguments strictly. Passing a hash where keywords are expected (or vice versa) now raises instead of silently coercing.

Stale method definition

A refactor changed a method definition but a caller (or an override/monkeypatch) was not updated to match.

How to fix it

Match the call to the current signature

  1. Open the method definition (or the gem source) for the version installed on the runner.
  2. Update the call site to pass the correct number and kind (positional vs keyword) of arguments.
  3. For Ruby 3 keyword changes, use explicit keywords or double-splat a hash with **.

Check the installed gem version

Confirm which version CI resolved so you debug against the right signature.

Terminal
bundle exec ruby -e 'require "the_gem"; p Gem.loaded_specs["the_gem"].version'

How to prevent it

  • Read upgrade changelogs for signature changes before bumping gems.
  • Keep call sites and definitions consistent during refactors.
  • Adopt Ruby 3 keyword-argument conventions explicitly.

Frequently asked questions

What causes ArgumentError: wrong number of arguments in CI?
There are 3 common causes: gem signature changed, keyword vs positional in ruby 3, and stale method definition. An upgraded gem changed a method to take keyword arguments or fewer positional ones, but your call still passes the old positional list.
How do I fix ArgumentError: wrong number of arguments in CI?
There are 2 fixes depending on which cause you have: match the call to the current signature and check the installed gem version. Work through them in order, since the first is the most common.
What does ArgumentError: wrong number of arguments in CI actually mean?
A test or boot fails with ArgumentError stating given vs expected counts.
How do I stop ArgumentError: wrong number of arguments in CI happening again?
Read upgrade changelogs for signature changes before bumping gems. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card