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.
app/models/user.rb:14:5: C: Style/StringLiterals: Prefer single-quoted strings.
name = "admin"
^^^^^^^
1 file inspected, 1 offense detectedCommon 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
- Invoke rubocop via bundle exec so CI uses the locked version.
- Fix the reported offenses, or autocorrect the safe ones.
- Re-run to confirm a clean exit 0.
bundle exec rubocop
bundle exec rubocop -aPin the linter and config
Lock rubocop and its plugins so the same version runs everywhere, and keep .rubocop.yml committed.
gem 'rubocop', '1.65.1', require: falseHow 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.