Skip to content
Latchkey

Ruby NoMethodError / "Did you mean?" Typo in CI

Ruby raised a NoMethodError or NameError and the built-in did_you_mean gem offered a close match. The error is a genuine typo or a method that does not exist on that object - not a transient failure.

What this error means

A call fails with "undefined method 'X' for ..." (NoMethodError) or "undefined local variable or method" and a "Did you mean? Y" line. The suggested name is usually what you meant.

Ruby traceback
NoMethodError: undefined method `lenght' for an instance of String
Did you mean?  length

Common causes

Misspelled method or variable name

The method or name does not exist as written. did_you_mean compares against the available methods and suggests the closest one - almost always the fix.

Method exists on a different object/version

The method exists on another class, or was added/removed in a different gem version, so it is undefined on the receiver you have. A dependency change can make a previously valid call disappear.

How to fix it

Apply the suggested name

Take the did_you_mean suggestion when it matches your intent.

Ruby
# undefined method 'lenght' -> use 'length'
"hello".length

Confirm the receiver and version

  1. Check the object’s class and that the method exists on it (respond_to?).
  2. If a gem upgrade removed the method, pin a compatible version or migrate to the new API.
  3. Keep did_you_mean enabled in CI so suggestions appear in logs.

How to prevent it

  • Run a linter (RuboCop) and tests in CI to catch typos before merge.
  • Pin or range-constrain gems so a method does not vanish on upgrade.
  • Keep did_you_mean enabled for helpful suggestions in CI output.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →