13

I am running into the following error when trying to install mimemagic 0.3.10 in a Ruby on Rails project. Note that it is run on a Windows environment. Here is the most relevant error stack trace:

Fetching mimemagic 0.3.10
Installing mimemagic 0.3.10 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
C:/Ruby26/lib/ruby/gems/2.6.0/gems/mimemagic-0.3.10/ext/mimemagic
C:/Ruby26/bin/ruby.exe -rrubygems
C:/Ruby26/lib/ruby/gems/2.6.0/gems/rake-13.0.6/exe/rake
RUBYARCHDIR\=C:/Ruby26/lib/ruby/gems/2.6.0/extensions/x86-mingw32/2.6.0/mimemagic-0.3.10    
RUBYLIBDIR\=C:/Ruby26/lib/ruby/gems/2.6.0/extensions/x86-mingw32/2.6.0/mimemagic-0.3.10     
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.

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.

Keep in mind I am answering this question myself as I have found a solution and want to share it with anyone else who might run into the same issue.

0

1 Answer 1

19

First, create a file named freedesktop.org.xml.

Then copy the file content found in this link and paste it into the file just created.

Finally, set the FREEDESKTOP_MIME_TYPES_PATH environment variable

Unix terminal:

export FREEDESKTOP_MIME_TYPES_PATH=/path/to/freedesktop.org.xml

Command prompt:

setx FREEDESKTOP_MIME_TYPES_PATH "\path\to\freedesktop.org.xml" 

Mac Users:

Try @jonathanHaar's suggestion below: "install via homebrew brew install shared-mime-info"

5
  • 2
    Thanks, this helped me, I have updated your answer with the location I have set. Oct 23, 2021 at 22:35
  • 45
    MAC Users: install via homebrew brew install shared-mime-info Jan 27, 2022 at 13:31
  • 1
    @JonathanHaar You should add that as an answer.
    – Gautam
    Jul 4, 2022 at 10:49
  • @JonathanHaar This works for me! Add it as an answer
    – zekromWex
    Jul 14, 2022 at 0:23
  • Questions closed and will not let me :shrug: Jul 27, 2022 at 1:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.