LoginSignup
15
7

More than 5 years have passed since last update.

CircleCIでのみrubocopがエラーになる

Posted at

現象

手元の開発環境ではrubocopに怒られない。

% bundle exec rubocop
Inspecting 31 files
...............................

31 files inspected, no offenses detected

だがしかし、CircleCIのコンテナで動かすとエラーになる!

スクリーンショット 2018-06-25 15.26.38.png

#!/bin/bash -eo pipefail
bundle exec rubocop
Error: The `Style/TrailingCommaInLiteral` cop no longer exists. Please use `Style/TrailingCommaInArrayLiteral` and/or `Style/TrailingCommaInHashLiteral` instead.
(obsolete configuration found in vendor/bundle/ruby/2.5.0/gems/public_suffix-3.0.2/.rubocop_defaults.yml, please update it)
Exited with code 2

原因

理由は簡単だった。bundle installしたgemsは手元ではシステム(というかrbenv)の配下にロードされるのに対して、CircleCIではvendor/bundle配下にロードするように指定してあった。

- run:
    name: install dependencies
    command: |
      yarn install
      bundle install --jobs=4 --retry=3 --path vendor/bundle

このためrubocopがvendor配下のgemsたちまでチェックしてしまっていたのだった。

対策

vendor配下をrubocopの対象外にすることで解決した。

AllCops:
  TargetRubyVersion: 2.5
  Exclude:
    - 'bin/**/*'
    - 'node_modules/**/*'
    - 'vendor/**/*'

参考

15
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
7