Ruby 3.0.3 にアップデートしたところ、bootsnap の影響で Rails が起動しなくなったので対応した

先日、Rubyのセキュリティリリースが出ていました。
Ruby 3.0.3 Released

 
そのため、Rubyのバージョンを 3.0.3 に上げたところ、RailsRSpec が起動しなくなったため、対応した時のメモを残します。

 

環境

 

エラー

Ruby 3.0.3 にアップデートした後で Rails を起動したところ、以下のエラーになりました。

% bundle exec rails s
path/to/vendor/bundle/ruby/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/compile_cache/iseq.rb:13:in `to_binary': wrong argument type false (expected Symbol) (TypeError)

 
RSpecも実行してみましたが

% bundle exec rspec  

An error occurred while loading ./spec/requests/api_spec.rb.
Failure/Error: require 'rspec/rails'

TypeError:
  wrong argument type false (expected Symbol)
# ./vendor/bundle/ruby/3.0.0/gems/bootsnap-1.9.1/lib/bootsnap/compile_cache/iseq.rb:13:in `to_binary'
...
No examples found.


Finished in 0.00009 seconds (files took 1.38 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

と、テストコードの実行前にエラーとなってしまいました。

 

対応

エラーに出ていた bootsnap のリポジトリを見たところ、issueやPRがありました。

 
issueを見たところ、bootsnap を 1.9.3 に上げると解消されるとのことでした。

 
そこで、 bootsnap をアップデートします。

% bundle update bootsnap

 
その後、 rails s したところ、無事に起動しました。

% bundle exec rails s
=> Booting Puma
=> Rails 6.1.4.1 application starting in development 
...

 
また、RSpecも実行し、テストがパスすることを確認しました。

% bundle exec rspec  

..............................

Finished in 0.61663 seconds (files took 1.74 seconds to load)
30 examples, 0 failures