6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GitHub Actions のcache を消したいとき

Posted at

GitHub Actions の cache があることで

例えば,setup-ruby などでは,bundle install 時の速度が速くなったりします.
これは,キャッシュでインストール済みの状態を復元して再インストールを回避している訳です.

これで困ることもある

例えば,GitHub Actions でOSに xxx-latest を指定していたとします.
この場合自動的に OS が上がってくれます.
良いことなんですが,悪い面もあります.

例えば,特定のnative gemが,キャッシュにインストール済みの状態だったとします.
それはリンクされているライブラリのバージョンが固定されていると考えることもできます.
それで,OS 側のライブラリのバージョンが上がってしまうと,
バージョンが合わなくなります.

例えば,今までCIが通っていたのに,下記のように,ライブラリが見つからない不思議な状態になります.
注意深く読むと,バージョンがズレていることがわかります.

  • Library not loaded: '/usr/local/opt/icu4c/lib/libicudata.73.dylib'
  • '/usr/local/Cellar/icu4c/74.2/lib/libicudata.73.dylib' (no such file)
    • ここで新バージョン(=74.2)がインストールされていることに気付けるかも
log
/Users/runner/hostedtoolcache/Ruby/3.1.4/x64/bin/ruby -I/Users/runner/work/qiita-markdown/qiita-markdown/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.13.0/lib:/Users/runner/work/qiita-markdown/qiita-markdown/vendor/bundle/ruby/3.1.0/gems/rspec-support-3.13.1/lib /Users/runner/work/qiita-markdown/qiita-markdown/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.13.0/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb

An error occurred while loading spec_helper. - Did you mean?
                    rspec ./spec/spec_helper.rb

Failure/Error: require "linguist"

LoadError:
  dlopen(/Users/runner/work/qiita-markdown/qiita-markdown/vendor/bundle/ruby/3.1.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes/charlock_holmes.bundle, 0x0009): Library not loaded: '/usr/local/opt/icu4c/lib/libicudata.73.dylib'
    Referenced from: '/Users/runner/work/qiita-markdown/qiita-markdown/vendor/bundle/ruby/3.1.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes/charlock_holmes.bundle'
    Reason: tried: '/usr/local/opt/icu4c/lib/libicudata.73.dylib' (no such file), '/usr/local/lib/libicudata.73.dylib' (no such file), '/usr/lib/libicudata.73.dylib' (no such file), '/usr/local/Cellar/icu4c/74.2/lib/libicudata.73.dylib' (no such file), '/usr/local/lib/libicudata.73.dylib' (no such file), '/usr/lib/libicudata.73.dylib' (no such file) - /Users/runner/work/qiita-markdown/qiita-markdown/vendor/bundle/ruby/3.1.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes/charlock_holmes.bundle
# ./vendor/bundle/ruby/3.1.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes.rb:1:in `require'
# ./vendor/bundle/ruby/3.1.0/gems/charlock_holmes-0.7.7/lib/charlock_holmes.rb:1:in `<top (required)>'
# ./vendor/bundle/ruby/3.1.0/gems/github-linguist-7.29.0/lib/linguist/blob_helper.rb:3:in `require'
# ./vendor/bundle/ruby/3.1.0/gems/github-linguist-7.29.0/lib/linguist/blob_helper.rb:3:in `<top (required)>'
# ./vendor/bundle/ruby/3.1.0/gems/github-linguist-7.29.0/lib/linguist.rb:1:in `require'
# ./vendor/bundle/ruby/3.1.0/gems/github-linguist-7.29.0/lib/linguist.rb:1:in `<top (required)>'
# ./lib/qiita/markdown.rb:3:in `require'
# ./lib/qiita/markdown.rb:3:in `<top (required)>'
# ./lib/qiita-markdown.rb:1:in `require'
# ./lib/qiita-markdown.rb:1:in `<top (required)>'
# ./spec/spec_helper.rb:11:in `require'
# ./spec/spec_helper.rb:11:in `<top (required)>'
No examples found.

解決する

setup-ruby の場合は,こんなログなので,マッチするキャッシュを消せば,再インストールが走るので,バージョンのミスマッチが無くなります.
(= Found cache for key: ログが無くなる)

  • key:setup-ruby-bundler-cache-v6-macos-12-x64-ruby-3.1.4-wd-/Users/runner/work/qiita-markdown/qiita-markdown-with--without--only--Gemfile.lock-
ログ
> bundle install
/Users/runner/hostedtoolcache/Ruby/3.1.4/x64/bin/bundle config --local path /Users/runner/work/qiita-markdown/qiita-markdown/vendor/bundle
/Users/runner/hostedtoolcache/Ruby/3.1.4/x64/bin/bundle lock
Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies...
Writing lockfile to /Users/runner/work/qiita-markdown/qiita-markdown/Gemfile.lock
Cache key: setup-ruby-bundler-cache-v6-macos-12-x64-ruby-3.1.4-wd-/Users/runner/work/qiita-markdown/qiita-markdown-with--without--only--Gemfile.lock-ec9f9d4c7646c60312db83796c5a05c6b6395628433090f701846eb4f710ef92
Received 37748736 of 44821255 (84.2%), 36.0 MBs/sec
Cache Size: ~43 MB (44821255 B)
/usr/local/bin/gtar -xf /Users/runner/work/_temp/aee0fc4c-f368-448e-bcbc-4f2f66d344e6/cache.tzst -P -C /Users/runner/work/qiita-markdown/qiita-markdown --delay-directory-restore --use-compress-program unzstd
Received 44821255 of 44821255 (100.0%), 21.4 MBs/sec
Cache restored successfully
Found cache for key: setup-ruby-bundler-cache-v6-macos-12-x64-ruby-3.1.4-wd-/Users/runner/work/qiita-markdown/qiita-markdown-with--without--only--Gemfile.lock-ec9f9d4c7646c60312db83796c5a05c6b6395628433090f701846eb4f710ef92

Refs

6
4
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
6
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?