Wanna see something cool? Check out Angular Spotify 🎧

bundle install: Could not find MIME type database in the following locations

Problem

I am running bundle install on a Ruby project and I got the following error:

Using dry-validation 1.10.0
Installing mimemagic 0.4.3 with native extensions
Installing rmagick 5.5.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/trung.vo/.asdf/installs/ruby/3.1.5/lib/ruby/gems/3.1.0/gems/mimemagic-0.4.3/ext/mimemagic
/Users/trung.vo/.asdf/installs/ruby/3.1.5/bin/ruby -I/Users/trung.vo/.asdf/installs/ruby/3.1.5/lib/ruby/3.1.0 -rrubygems
/Users/trung.vo/.asdf/installs/ruby/3.1.5/lib/ruby/gems/3.1.0/gems/rake-13.2.1/exe/rake
RUBYARCHDIR\=/Users/trung.vo/.asdf/installs/ruby/3.1.5/lib/ruby/gems/3.1.0/extensions/arm64-darwin-24/3.1.0/mimemagic-0.4.3
RUBYLIBDIR\=/Users/trung.vo/.asdf/installs/ruby/3.1.5/lib/ruby/gems/3.1.0/extensions/arm64-darwin-24/3.1.0/mimemagic-0.4.3
rake aborted!
Could not find MIME type database in the following locations: ["/usr/local/share/mime/packages/freedesktop.org.xml", "/opt/homebrew/share/mime/packages/freedesktop.org.xml",
"/opt/local/share/mime/packages/freedesktop.org.xml", "/usr/share/mime/packages/freedesktop.org.xml"]

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.

Tasks: TOP => default
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in /Users/trung.vo/.asdf/installs/ruby/3.1.5/lib/ruby/gems/3.1.0/gems/mimemagic-0.4.3 for inspection.
Results logged to /Users/trung.vo/.asdf/installs/ruby/3.1.5/lib/ruby/gems/3.1.0/extensions/arm64-darwin-24/3.1.0/mimemagic-0.4.3/gem_make.out

Here’s what the error looks like in the terminal:

bundle install error

Solution

  1. First, install the shared-mime-info package using Homebrew:
brew install shared-mime-info
  1. After fixing the MIME type issue, you might encounter another error related to RMagick:
An error occurred while installing rmagick (5.5.0), and Bundler cannot continue.

To fix this, install ImageMagick:

brew install imagemagick

Output

After installing both required packages, running bundle install again should complete successfully:

Using mustermann 3.0.0
Using mimemagic 0.4.3
Using rubocop 1.63.2
Using listen 3.9.0
Using rspec 3.13.0
Using aws-sdk-s3 1.147.0
Using sidekiq-scheduler 5.0.3
Using elasticsearch 7.13.0
Using dry-validation 1.10.0
Using sinatra 3.2.0
Using guard 2.18.1
Using sinatra-contrib 3.2.0
Using guard-rack 2.2.1
Using guard-bundler 3.0.1
Using guard-sidekiq 0.1.0
Installing rmagick 5.5.0 with native extensions
Bundle complete! 50 Gemfile dependencies, 157 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.

Wow, it works! bundle install success

Published 26 Feb 2025

    Read more

     — Netlify Redirects vs Gatsby Redirects: My Traffic Drop 90%
     — Understanding staleTime and gcTime (cacheTime) in React Query
     — Chrome DevTools Performance Panel: Analyze Your Website's Performance
     — Configuring Cloudflare Images and fixing ERROR 9421: Too many redirects
     — Sharing my go-to Gmail filter to clean up unnecessary Calendar notifications