Skip to content
Latchkey

RuboCop "offenses detected" exit code 1 in CI

RuboCop inspected the code, found offenses, and exited 1, which fails the CI job. The output lists each file, line, and cop; a sudden flood of new offenses usually means CI runs a different RuboCop version than your machine.

What this error means

A lint step ends with "N offenses detected" and exit code 1. The offenses may be real violations, or cops that behave differently because CI resolved a newer rubocop than local.

bundler
app/models/user.rb:14:5: C: Style/StringLiterals: Prefer single-quoted strings.
  name = "admin"
    ^^^^^^^

1 file inspected, 1 offense detected

Common causes

Genuine style or lint violations

The code violates enabled cops, so RuboCop reports offenses and exits non-zero.

A different RuboCop version in CI

CI resolved a newer rubocop (or plugin) than local, enabling cops or defaults that flag code that passed before.

How to fix it

Run RuboCop through the locked bundle

  1. Invoke rubocop via bundle exec so CI uses the locked version.
  2. Fix the reported offenses, or autocorrect the safe ones.
  3. Re-run to confirm a clean exit 0.
Terminal
bundle exec rubocop
bundle exec rubocop -a

Pin the linter and config

Lock rubocop and its plugins so the same version runs everywhere, and keep .rubocop.yml committed.

Gemfile
gem 'rubocop', '1.65.1', require: false

How to prevent it

  • Run rubocop via bundle exec with a pinned version.
  • Commit .rubocop.yml so config is identical in CI and local.
  • Use a .rubocop_todo.yml to gate legacy offenses.

Related guides

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