質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.47%
Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Q&A

解決済

2回答

2890閲覧

bundle installの結果、mimemagic (0.3.9)がインストールされていないとエラーが返ってくる

asm_t

総合スコア14

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

0グッド

0クリップ

投稿2021/03/26 15:59

プログラミング初心者です。

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/asamitakaoka/project/my_portfolio/vendor/bundle/ruby/2.7.0/gems/mimemagic-0.3.9/ext/mimemagic /Users/asamitakaoka/.rbenv/versions/2.7.0/bin/ruby -I/Users/asamitakaoka/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems -rrubygems /Users/asamitakaoka/project/my_portfolio/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/exe/rake RUBYARCHDIR\=/Users/asamitakaoka/project/my_portfolio/vendor/bundle/ruby/2.7.0/extensions/x86_64-darwin-19/2.7.0/mimemagic-0.3.9 RUBYLIBDIR\=/Users/asamitakaoka/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/asamitakaoka/project/my_portfolio/vendor/bundle/ruby/2.7.0/gems/mimemagic-0.3.9/ext/mimemagic/Rakefile:14:in `locate_mime_database' /Users/asamitakaoka/project/my_portfolio/vendor/bundle/ruby/2.7.0/gems/mimemagic-0.3.9/ext/mimemagic/Rakefile:25:in `block in <top (required)>' /Users/asamitakaoka/project/my_portfolio/vendor/bundle/ruby/2.7.0/gems/rake-13.0.3/exe/rake:27:in `<main>' Tasks: TOP => default (See full trace by running task with --trace) rake failed, exit code 1 Gem files will remain installed in /Users/asamitakaoka/project/my_portfolio/vendor/bundle/ruby/2.7.0/gems/mimemagic-0.3.9 for inspection. Results logged to /Users/asamitakaoka/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'を実行した結果

Fetching

1Building native extensions. This could take a while... 2ERROR: Error installing mimemagic: 3 ERROR: Failed to build gem native extension. 4 5 current directory: /Users/asamitakaoka/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/mimemagic-0.3.9/ext/mimemagic 6/Users/asamitakaoka/.rbenv/versions/2.7.0/bin/ruby -I/Users/asamitakaoka/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems -rrubygems /Users/asamitakaoka/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/rake-13.0.3/exe/rake RUBYARCHDIR\=/Users/asamitakaoka/.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/asamitakaoka/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/extensions/x86_64-darwin-19/2.7.0/mimemagic-0.3.9 7rake aborted! 8Could 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"] 9 10Ensure you have either installed the shared-mime-info package for your distribution, or 11obtain a version of freedesktop.org.xml and set FREEDESKTOP_MIME_TYPES_PATH to the location 12of that file. 13 14Tasks: TOP => default 15(See full trace by running task with --trace) 16 17rake failed, exit code 1 18 19Gem files will remain installed in /Users/asamitakaoka/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/mimemagic-0.3.9 for inspection. 20Results logged to /Users/asamitakaoka/.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 21コード

このエラーはどうしたら解決できるのでしょうか。
ネットでエラー文を調べても分からなかったため、
教えていただきたいです。

よろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

asm_t

2021/03/27 01:30

hoshi-takanori様 macOS で Homebrew を使用しているため、ご回答いただいたようにbrew install shared-mime-info を実行したところ、無事にbundle installできました!! 添付いただいた記事も参考になりました。 この度は、ご教示いただきありがとうございました。
asm_t

2021/03/27 01:41

hoshi-takanori様 お陰様で解決できましたので、ベストアンサーにさせていただきたいのですが、こちらの欄ではベストアンサーを選択できないようなので、お手数ですが回答欄のほうに再度同じ内容を投稿いただくことは可能でしょうか。
guest

回答2

0

ベストアンサー

Rails の依存ライブラリ mimemagic が利用していたデータファイルにライセンス上の問題が発覚したため、そのファイルは別途入手するように仕様変更があり、mimemagic の過去のバージョンが入手できなくなりました。

このため、mimemagic を最新版にした上で、問題のデータファイルを別途入手する必要があり、

  • macOS で Homebrew を使っている場合は、brew install shared-mime-info を実行
  • heroku ではそのファイルは heroku 側で用意してくれているので、mimemagic のバージョンを新しくした Gemfile.lock を push するだけで OK

ということのようです。

なお、その後 Rails 側で mimemagic に依存しないようにする修正があり、Rails を最新のマイナーバージョン (5.2.5 / 6.0.3.6 / 6.1.3.1) に更新すればこの問題はなくなります。
参考: mimemagicの最新動向 - HackMD

投稿2021/03/27 04:47

hoshi-takanori

総合スコア7895

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

asm_t

2021/03/27 04:57 編集

hoshi-takanori様 ご丁寧に、わかりやすく教えてくださりありがとうございます。 大変勉強になりました。
guest

0

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.

は、下記のどちらかを実行しろと言うことです。
案1:OSのパッケージ管理コマンドで、shared-mime-infoをインストールする
案2:freedesktop.org.xmlというファイルをどこかから入手して、そのファイルのフルパスを環境変数FREEDESKTOP_MIME_TYPES_PATHにセットする

投稿2021/03/26 16:23

otn

総合スコア84645

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

asm_t

2021/03/27 01:34

otn様 macOS で Homebrew を使用しているため、hoshi-takanori 様のアドバイスのとおりにbrew install shared-mime-infoを実行しましたたところ、無事にbundle installできましたが、 案1、案2を教えてくださりありがとうございました。 大変勉強になりました。 またおせわになることがあるかもしれませんが、そのときは何卒よろしくお願いいたします。
otn

2021/03/27 02:05

Building native extensions. の際のエラーの大半は、必要なパッケージがインストールされていないことです。 何をインストールすれば良いかはエラーメッセージに書いてあることが多いです。書いてないこともありますが。
asm_t

2021/03/27 02:14

otn様 なるほど、もっとエラーメッセージを読み解く力を今後身につけていかなければならないなと感じました。 ありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.47%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問