LoginSignup
1
0

More than 3 years have passed since last update.

【備忘録】【エラー解決】bundle installの結果、mimemagic (0.3.9)がインストールされていないとエラーが返ってきたら

Posted at

git push heroku masterを実行してHerokuにデプロイしたいのに、
エラー続きで訳が分からなくなってきたので
自分が忘れないためにも記録を残しておきます。

git push heroku masterを実行した結果

Enumerating objects: 2637, done.
Counting objects: 100% (2637/2637), done.
Delta compression using up to 4 threads
Compressing objects: 100% (2498/2498), done.
Writing objects: 100% (2637/2637), 13.82 MiB | 87.00 KiB/s, done.
Total 2637 (delta 216), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-18 stack
remote: -----> Determining which buildpack to use for this app
remote: ! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used.
remote: Detected buildpacks: Ruby,Node.js
remote: See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order
remote: -----> Ruby app detected
remote: grep: /tmp/build_95e57356/Gemfile.lock: No such file or directory
remote: -----> Compiling Ruby/NoLockfile
remote:
remote: !
remote: ! Gemfile.lock required. Please check it in.
remote: !
remote: ! Push rejected, failed to compile Ruby app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to polar-citadel-69285.
remote:
To https://git.heroku.com/polar-citadel-69285.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/polar-citadel-69285.git'

↑上記エラー文を読むと、「Gemfile.lockが必要」と書いてありました。
調べたところ、bundle installを実行した際にBundlerがGemfile.lockを生成するということがわかったため、bundle installを実行してみました。

bundle installを実行した結果

Fetching gem metadata from https://rubygems.org/............
Resolving dependencies.....
Using rake 13.0.3
Using concurrent-ruby 1.1.8
Using minitest 5.14.4
Using zeitwerk 2.4.2
Using builder 3.2.4
Using erubi 1.10.0
Using racc 1.5.2
Using crass 1.0.6
Using rack 2.2.3
Using nio4r 2.5.7
Using websocket-extensions 0.1.5
Fetching mini_mime 1.0.3
Fetching bindex 0.8.1
Fetching public_suffix 4.0.6
Fetching msgpack 1.4.2
Installing bindex 0.8.1 with native extensions
Installing mini_mime 1.0.3
Using bundler 2.2.11
Installing msgpack 1.4.2 with native extensions
Installing public_suffix 4.0.6
Fetching byebug 11.1.3
Installing byebug 11.1.3 with native extensions
Fetching childprocess 3.0.0
Fetching regexp_parser 2.1.1
Installing childprocess 3.0.0
Installing regexp_parser 2.1.1
Fetching ffi 1.15.0
Fetching method_source 1.0.0
Fetching rb-fsevent 0.10.4
Fetching thor 1.1.0
Installing method_source 1.0.0
Fetching rubyzip 2.3.0
Installing rb-fsevent 0.10.4
Fetching tilt 2.0.10
Installing rubyzip 2.3.0
Fetching semantic_range 3.0.0
Installing tilt 2.0.10
Installing thor 1.1.0
Fetching spring 2.1.1
Installing semantic_range 3.0.0
Fetching sqlite3 1.4.2
Fetching turbolinks-source 5.2.0
Installing turbolinks-source 5.2.0
Using i18n 1.8.9
Using tzinfo 2.0.4
Using nokogiri 1.11.2 (x86_64-darwin)
Using rack-test 1.1.0
Using websocket-driver 0.7.3
Fetching puma 5.2.2
Installing sqlite3 1.4.2 with native extensions
Installing spring 2.1.1
Installing puma 5.2.2 with native extensions
Installing ffi 1.15.0 with native extensions
Fetching rack-mini-profiler 2.3.1
Installing rack-mini-profiler 2.3.1
Fetching rack-proxy 0.6.5
Fetching mail 2.7.1
Fetching sprockets 4.0.2
Fetching addressable 2.7.0
Installing rack-proxy 0.6.5
Fetching bootsnap 1.7.3
Installing sprockets 4.0.2
Fetching selenium-webdriver 3.142.7
Installing bootsnap 1.7.3 with native extensions
Using activesupport 6.1.3
Using loofah 2.9.0
Fetching mimemagic 0.3.9
Installing addressable 2.7.0
Fetching xpath 3.2.0
Installing mimemagic 0.3.9 with native extensions
Fetching turbolinks 5.2.1
Installing xpath 3.2.0
Fetching rb-inotify 0.10.1
Installing turbolinks 5.2.1
Fetching sassc 2.4.0
Installing mail 2.7.1
Using rails-dom-testing 2.0.3
Using globalid 0.4.2
Using activemodel 6.1.3
Fetching jbuilder 2.11.2
Installing rb-inotify 0.10.1
Using rails-html-sanitizer 1.3.0
Fetching capybara 3.35.3
Installing jbuilder 2.11.2
Using activejob 6.1.3
Using activerecord 6.1.3
Fetching listen 3.5.0
Installing listen 3.5.0
Using actionview 6.1.3
Using actionpack 6.1.3
Using actioncable 6.1.3
Fetching actionmailer 6.1.3
Installing actionmailer 6.1.3
Fetching railties 6.1.3
Installing sassc 2.4.0 with native extensions
Installing railties 6.1.3
Installing capybara 3.35.3
Installing selenium-webdriver 3.142.7
Fetching sprockets-rails 3.2.2
Installing sprockets-rails 3.2.2
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/ユーザー名/project/my_portfolio/vendor/bundle/ruby/2.7.0/gems/mimemagic-0.3.9/ext/mimemagic
/Users/ユーザー名/.rbenv/versions/2.7.0/bin/ruby
-I/Users/ユーザー名/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems -rrubygems
/Users/ユーザー名/project/my_portfolio/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/exe/rake
RUBYARCHDIR=/Users/ユーザー名/project/my_portfolio/vendor/bundle/ruby/2.7.0/extensions/x86_64-darwin-19/2.7.0/mimemagic-0.3.9
RUBYLIBDIR=/Users/ユーザー名/project/my_portfolio/vendor/bundle/ruby/2.7.0/extensions/x86_64-darwin-19/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"]

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.
/Users/ユーザー名/project/my_portfolio/vendor/bundle/ruby/2.7.0/gems/mimemagic-0.3.9/ext/mimemagic/Rakefile:14:in
locate_mime_database'
/Users/ユーザー名/project/my_portfolio/vendor/bundle/ruby/2.7.0/gems/mimemagic-0.3.9/ext/mimemagic/Rakefile:25:in
block in '
/Users/ユーザー名/project/my_portfolio/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/exe/rake:27:in `'
Tasks: TOP => default
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in
/Users/ユーザー名/project/my_portfolio/vendor/bundle/ruby/2.7.0/gems/mimemagic-0.3.9 for inspection.
Results logged to
/Users/ユーザー名/project/my_portfolio/vendor/bundle/ruby/2.7.0/extensions/x86_64-darwin-19/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.

In Gemfile:
rails was resolved to 6.1.3, which depends on
actionmailbox was resolved to 6.1.3, which depends on
activestorage was resolved to 6.1.3, which depends on
marcel was resolved to 0.3.3, which depends on
mimemagic

↑上記エラー文にあるようにmimemagic (0.3.9)がインストールされていなかったため、
gem install mimemagic -v '0.3.9'を実行しました。

gem install mimemagic -v '0.3.9'を実行した結果

Building native extensions. This could take a while...
ERROR: Error installing mimemagic:
ERROR: Failed to build gem native extension.

current directory: /Users/ユーザー名/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/mimemagic-0.3.9/ext/mimemagic
/Users/ユーザー名/.rbenv/versions/2.7.0/bin/ruby -I/Users/ユーザー名/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems -rrubygems /Users/ユーザー名/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rake-13.0.3/exe/rake RUBYARCHDIR=/Users/ユーザー名/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-19/2.7.0/mimemagic-0.3.9 RUBYLIBDIR=/Users/ユーザー名/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-19/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"]

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.

Tasks: TOP => default
(See full trace by running task with --trace)

rake failed, exit code 1

Gem files will remain installed in /Users/ユーザー名/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/mimemagic-0.3.9 for inspection.
Results logged to /Users/ユーザー名/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-19/2.7.0/mimemagic-0.3.9/gem_make.out

↑上記エラーはmimemagicを最新版に上げてください、という内容だと分かりました。
私の場合はmacOS、Homebrewを使用しているため、
brew install shared-mime-infoを実行したところエラー解消ができました。
【参考URL】
https://hackmd.io/@mametter/mimemagic-info-ja

その上でbundle installをしたところ、無事に通りました!!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0