'mimemagic install error: "Could not find MIME type database in the following locations..." on Windows [duplicate]
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.
Solution 1:[1]
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"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | heyitsalec |