Failed to build gem native extension when bundling mimemagic

If you are trying to install mimemagic with bundle install or gem install on a Mac, you might receive an error

ERROR:  Error installing mimemagic:
        ERROR: Failed to build gem native extension.

Additionally your error might include

Could not find MIME type database in the following locations: ["/usr/local/share/mime/packages/", "/opt/homebrew/share/mime/packages/", "/opt/local/share/mime/packages/", "/usr/share/mime/packages/"]

To fix this, run the following:

brew install shared-mime-info

Once that has completed, run bundle again or gem install mimemagic.

← Previous Next →