会社で開発しているRailsアプリケーションをTravis CIで回しているんだけど、bundlerでインストールされるgemのキャッシュが効いておらずログにこんな出力が出ていた。
store build cache
$ bundle clean
Cleaning all the gems on your system is dangerous! If you're sure you want to remove every system gem not in this bundle, run `bundle clean --force`.
0.00s
1.60schanges detected, packing new archive
FAILED: tar -Pzcf /home/travis/.casher/push.tgz
tar: Cowardly refusing to create an empty archive
Try `tar --help' or `tar --usage' for more information.
uploading archive
failed to upload cache
curl: Can't open '/home/travis/.casher/push.tgz'!
curl: try 'curl --help' or 'curl --manual' for more information
よくよく調べてみると
の2つが原因のようだった。.travis.ymlでいうとこんな感じ。
install:
- cd $TRAVIS_BUILD_DIR/rails_root && bundle install --jobs=3 --retry=3
cache:
bundler: true
なのでbundlerでのインストール先とキャッシュ対象を明示的に指定することで解決した。
install:
- cd $TRAVIS_BUILD_DIR/rails_root && bundle install --jobs=3 --retry=3 --path vendor/bundle
cache:
directories:
- rails_root/vendor/bundle
本当はちゃんとbundle clean
で古くなったgemを削除しないと徐々にキャッシュサイズが大きくなるらしいけど、ひとまずはこれで。
参考
github.com