`require': cannot load such file -- mimemagic/overlay (LoadError)への対処手順
起こったこと
gem 'carrierwave', '~> 2.0'
をbundle install
したあとにrails g uploader
を実行するとエラーが発生した
環境
- Docker(Ubuntu)
- Rails 6.0.3.6
- ruby 2.7.2
- carrierwave 2.0
- mimemagic 0.3
エラー解消までにやったこと
apt-get update shared-mime-info
でshared-mime-infoをインストールapt-get upgrade shared-mime-info
でshared-mime-infoをupgradeGemfile
にgem 'mimemagic', '0.3.9'
を追加carrierwave
を2.2
にアップデートGemfile.lock
のcarrierwaveが依存しているmimemagic
のバージョンを(=0.3.9)
に指定した
carrierwave (2.2.0) activemodel (>= 5.0.0) activesupport (>= 5.0.0) addressable (~> 2.6) image_processing (~> 1.1) mimemagic (= 0.3.9)
- 本来であれば
Gemfile.lock
を直接修正するのは推奨されていないようだが、carrierwave
が依存するmimemagic
はGemfile上では修正できなかった Gemfile.lock
を直接修正することで、carrierwave
の依存先のmimemagic
のバージョンを手動で変更できたbundle update mimemagic
でmimemagic
をアップデート
エラーメッセージ
root@e816625f7a06:/apps/techpit-match# rails g uploader ProfileImage /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': cannot load such file -- mimemagic/overlay (LoadError) from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:89:in `register' from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:44:in `require' from /usr/local/bundle/gems/activesupport-6.0.3.6/lib/active_support/dependencies.rb:324:in `block in require' from /usr/local/bundle/gems/activesupport-6.0.3.6/lib/active_support/dependencies.rb:291:in `load_dependency' from /usr/local/bundle/gems/activesupport-6.0.3.6/lib/active_support/dependencies.rb:324:in `require' from /usr/local/bundle/gems/carrierwave-2.2.0/lib/carrierwave/sanitized_file.rb:5:in `<main>' from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from /usr/local/bundle/gems/activesupport-6.0.3.6/lib/active_support/dependencies.rb:324:in `block in require' from /usr/local/bundle/gems/activesupport-6.0.3.6/lib/active_support/dependencies.rb:291:in `load_dependency' from /usr/local/bundle/gems/activesupport-6.0.3.6/lib/active_support/dependencies.rb:324:in `require' from /usr/local/bundle/gems/carrierwave-2.2.0/lib/carrierwave.rb:99:in `<main>' from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require' from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi' from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register' from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi' from /usr/local/bundle/gems/bootsnap-1.7.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require' from /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:74:in `block (2 levels) in require' from /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:69:in `each' from /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:69:in `block in require' from /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:58:in `each' from /usr/local/lib/ruby/2.7.0/bundler/runtime.rb:58:in `require' from /usr/local/lib/ruby/2.7.0/bundler.rb:174:in `require' from /apps/techpit-match/config/application.rb:7:in `<top (required)>' from /usr/local/bundle/gems/spring-2.1.1/lib/spring/application.rb:92:in `require' from /usr/local/bundle/gems/spring-2.1.1/lib/spring/application.rb:92:in `preload' from /usr/local/bundle/gems/spring-2.1.1/lib/spring/application.rb:157:in `serve' from /usr/local/bundle/gems/spring-2.1.1/lib/spring/application.rb:145:in `block in run' from /usr/local/bundle/gems/spring-2.1.1/lib/spring/application.rb:139:in `loop' from /usr/local/bundle/gems/spring-2.1.1/lib/spring/application.rb:139:in `run' from /usr/local/bundle/gems/spring-2.1.1/lib/spring/application/boot.rb:19:in `<top (required)>' from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require' from /usr/local/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:72:in `require' from -e:1:in `<main>'
原因詳細
原因詳細は以下の記事を参照。
mimemagicに含まれるshared-mime-infoがGPL2.0だっため、これを取り除いたことによって、MITになった。 しかし、それを自分でインストールしないといけなくなった。