mimemagic 安装错误:“在以下位置找不到 MIME 类型数据库...”在 Windows [重复]

Posted

技术标签:

【中文标题】mimemagic 安装错误:“在以下位置找不到 MIME 类型数据库...”在 Windows [重复]【英文标题】:mimemagic install error: "Could not find MIME type database in the following locations..." on Windows [duplicate] 【发布时间】:2021-11-13 18:53:26 【问题描述】:

尝试在 Ruby on Rails 项目中安装 mimemagic 0.3.10 时遇到以下错误。请注意,它是在 Windows 环境中运行的。这是最相关的错误堆栈跟踪:

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.

请记住,我自己回答了这个问题,因为我找到了解决方案,并希望与可能遇到相同问题的其他人分享。

【问题讨论】:

【参考方案1】:

首先,创建一个名为freedesktop.org.xml的文件。

然后复制这个link中找到的文件内容,粘贴到刚刚创建的文件中。

最后,设置FREEDESKTOP_MIME_TYPES_PATH环境变量

Unix 终端:

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

命令提示符:

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

【讨论】:

谢谢,这对我有帮助,我已经用我设置的位置更新了你的答案。 MAC 用户:通过自制软件安装brew install shared-mime-info

以上是关于mimemagic 安装错误:“在以下位置找不到 MIME 类型数据库...”在 Windows [重复]的主要内容,如果未能解决你的问题,请参考以下文章

Travis CI - 无法查询测试包中的测试用例列表:找不到测试包

您的捆绑包被锁定为 mimemagic (0.3.5),但在您的 Gemfile 中列出的任何源中都找不到该版本 [重复]

ArgumentError:升级 Rails 6.1.3 时出现错误数量的参数错误

Windows 10 中的 gacutil.exe 在哪里?

安装程序出现2502、2503错误解决方法

Oracle 安装时错误