27

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

42

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"

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks, this helped me, I have updated your answer with the location I have set.
MAC Users: install via homebrew brew install shared-mime-info
@JonathanHaar You should add that as an answer.
@JonathanHaar This works for me! Add it as an answer
Questions closed and will not let me :shrug:

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.