[英]docker build error Gem::Ext::BuildError: ERROR: Failed to build gem native extension for mimemagic-0.3.9
I have to build a docker image on my local machine to verify whether it is a building an image or not but I am facing this issue while building the docker image on a local machine.我必须在本地计算机上构建 docker 映像以验证它是否是在构建映像,但是在本地计算机上构建 docker 映像时遇到了这个问题。
Installing mime magic 0.3.9 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /usr/local/bundle/gems/mimemagic-0.3.9/ext/mimemagic
/usr/local/bin/ruby -I/usr/local/lib/ruby/2.7.0/rubygems -rrubygems
/usr/local/lib/ruby/gems/2.7.0/gems/rake-13.0.1/exe/rake
RUBYARCHDIR\=/usr/local/bundle/extensions/x86_64-linux/2.7.0/mimemagic-0.3.9
RUBYLIBDIR\=/usr/local/bundle/extensions/x86_64-linux/2.7.0/mimemagic-0.3.9
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",
"/usr/share/mime/packages/freedesktop.org.xml"]
/usr/local/bundle/gems/mimemagic-0.3.9/ext/mimemagic/Rakefile:25:in `block in
<top (required)>'
Tasks: TOP => default
(See full trace by running task with --trace)
rake failed, exit code 1
Gem files will remain installed in /usr/local/bundle/gems/mimemagic-0.3.9 for
inspection.
Results logged to
/usr/local/bundle/extensions/x86_64-linux/2.7.0/mimemagic-0.3.9/gem_make.out
An error occurred while installing mimemagic (0.3.9), and Bundler cannot
continue.
Make sure that `gem install mimemagic -v '0.3.9' --source
'https://rubygems.org/'` succeeds before bundling.
Modify the Dockerfile
to install the shared-mime-info
package.修改Dockerfile
以安装shared-mime-info
package。 Eg on Debian-based images:例如在基于 Debian 的图像上:
RUN apt-get update && apt-get install -y shared-mime-info
If it still won't work, then you may need to update the mimemagic
gem.如果它仍然不起作用,那么您可能需要更新mimemagic
gem。 On your host, update mimemagic
in the Rails app's Gemfile
/ Gemfile.lock
.在您的主机上,更新 Rails 应用程序的Gemfile
/ mimemagic
中的Gemfile.lock
。 You may need to install shared-mime-info
first: If the host is macOS, you may need to run brew install shared-mime-info
;您可能需要先安装shared-mime-info
:如果主机是 macOS,您可能需要运行brew install shared-mime-info
; if the host is Ubuntu, you may need to run apt-get install shared-mime-info
.如果主机是 Ubuntu,您可能需要运行apt-get install shared-mime-info
。 Then run然后运行
bundle update mimemagic
If your Dockerfile
downloads the Rails app from a repo, push your changes to that repo first.如果您的Dockerfile
从存储库下载 Rails 应用程序,请先将更改推送到该存储库。 Or, for testing, modify the Dockerfile
to copy in the Rails app from the host instead.或者,为了测试,修改Dockerfile
以从主机复制到 Rails 应用程序中。
If you are using macOS, try the following如果您使用的是 macOS,请尝试以下操作
brew install shared-mime-info
bundle update mimemagic
And the try to bundle your gem file并尝试捆绑您的 gem 文件
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.