When performing a
bundle install for a Rails 6.1.3 + Ruby 3.0.0 on macOS Catalina or Big Sur, you may run into the following error:
Gem::Ext::BuildError: ERROR: Failed to build gem native extension. ... Ensure you have either installed the shared-mime-info package for your distribution, or obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to the location of that file. This gem might be installed as a dependency of some bigger package, such as rails, activestorage, axlsx or cucumber. While most of these packages use the functionality of this gem, some gems have included this gem by accident. Set USE_FREEDESKTOP_PLACEHOLDER=true if you are certain that you do not need this gem, and wish to skip the inclusion of freedesktop.org.xml. The FREEDESKTOP_PLACEHOLDER option is meant as a transitional feature, and will be deprecated in the next release. ...
If this happens, you will need to install the shared-mime-info package for macOS.
> brew install shared-mime-info
If the preceding command fails, it is most likely due to some missing Xcode dev tools that need to be installed so the package can be properly compiled for your distribution of macOS. The error messages you receive will tell you exactly the Xcode dev tools that need to be installed as well as the command to execute to make it happen.
Better yet, if you can, upgrade your Rails project to version 220.127.116.11 or higher, as the 0.0.0.1 revision was created to fix the shared-mime-info defect caused by the mimemagic gem.