[RAILS] [Error] `cannot load such file --mime/types/data (LoadError)`

Introduction

If you write payjp in Gemfile and do rails s after bundle installs, a lot of characters will be listed. cannot load such file -- mime/types/data (LoadError) I wrote an article about the process that was resolved when such an error occurred. I think that there are different solutions depending on the environment and how to reach the error, so please use it as a reference only ~

environment

macOS Catalina version 10.15.7 Homebrew 2.7.1 rbenv 1.1.2 ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19] gem 3.2.4 Bundler version 2.1.4

error

Error statement

cannot load such file -- mime/types/data (LoadError) When I checked the error part where a lot of characters were listed, there was a sentence that MIME :: Types was already defined.

Confirmation and consideration

I checked the local gem with gem list.

スクリーンショット 2020-12-29 16.06.42.png mime-types-data is set to the default that can contain 2 versions. Mmm, is this bad? ??

After a lot of research, it seems that gem update --default is set for default. I haven't done that, but when I hit this command, it seems that the latest version of gem is installed at once and the latest version is set as the default.

Correspondence

For the time being, I decided to uninstall it and remove the default. First, cancel the default

Terminal


cd #Move to home directory
cd /Users/[username]/.rbenv/versions/[version]/lib/ruby/gems/[version]
 #Go to the path confirmed above
ls #Check inside
build_info  doc gems
cache extensions specifications ← The default settings are described in this

rm -rf specifications/default/ 
 #Delete the default directory in the specifications (this will remove the default)

Uninstalling mime-types-data

Terminal


gem uninstall mime-types-data
bundle install

confirm.

gem list

スクリーンショット 2021-01-02 14.39.21.png There was only one version and default was canceled.

Write payjpm in Gemfile, bundle install, rails s and the server started!

Summary

This error was due to mime-types-data. Although it is not described in the text, it took three days to resolve the results due to the occurrence of secondary and tertiary disasters by executing the investigation without thinking about anything. It is recommended that you understand what the commands in the terminal are for and how they work.

reference

https://qiita.com/zQmjRAb73seN5RM/items/ecb9e19ee8f3e9af6018

https://mophie-blog.com/2020/08/17/oops-i-did-gem-update-not-bundle-update-rails-no-work/

https://qiita.com/Okame-chan/items/39052dc4d4c3cebfb1ee

Recommended Posts

[Error] `cannot load such file --mime/types/data (LoadError)`
When you get LoadError (cannot load such file --ruby_file) when you require in Ruby
Resolve LoadError (cannot load such file --bcrypt) that occurs in rails test (Rails tutorial Chapter 6)
[Ruby] What to do when the error "cannot load such file" appears when executing VS Code debug
No such file or directory @ rb_sysopen --Error like public/user_images/1.jpg
rbenv install 2.7.1 fails with "no acceptable C compiler found in $ PATH" and "cannot load such file"