背景
2022/12月になってからgithub actionでdb migrate周りでエラーになり出したので対処の覚書。
(原因を完全に特定しているわけではないのでさっくり)
エラー内容抜粋
LoadError: libffi.so.7: cannot open shared object file: No such file or directory - /home/runner/work/appname/vendor/bundle/ruby/3.0.0/gems/ffi-1.15.5/lib/ffi_c.so
/home/runner/work/appname/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/home/runner/work/appname/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/home/runner/work/appname/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in `block in require'
/home/runner/work/appname/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:299:in `load_dependency'
/home/runner/work/appname/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in `require'
/home/runner/work/appname/vendor/bundle/ruby/3.0.0/gems/ffi-1.15.5/lib/ffi.rb:5:in `rescue in <main>'
/home/runner/work/appname/vendor/bundle/ruby/3.0.0/gems/ffi-1.15.5/lib/ffi.rb:2:in `<main>'
/home/runner/work/appname/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/home/runner/work/appname/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.15.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/home/runner/work/appname/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in `block in require'
/home/runner/work/appname/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:299:in `load_dependency'
/home/runner/work/appname/vendor/bundle/ruby/3.0.0/gems/activesupport-6.1.4.6/lib/active_support/dependencies.rb:332:in `require'
...
似ていそうな問題
https://github.com/ffi/ffi/issues/881
https://github.com/orgs/community/discussions/24949
当方も ruby/setup-ruby@v1
を利用しており、bundlerのキャッシュが効いている状態でffi周りのファイルが足りないと言うエラーが発生した。
対応
github actionのymlで cache-version
を変更
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
ruby-version: 3.0.2
- cache-version: 1
+ cache-version: 2