heroku Herokuにdeployすると "mimemagic" が原因でdeployできない

本稿について

本稿はサイト運営者が学んだことなどを記したメモの内容です。
全てが正確な情報とは限りません。ご注意ください。また修正するべき点は適時修正していきます
herokuにdeployした時に以下のエラーが発生
remote:  !
remote:  !    Failed to install gems via Bundler.
remote:  !
remote:  !    Push rejected, failed to compile Ruby app.
remote:
remote:  !    Push failed

おかしいのでlocalで bundle install をして確認してみる

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.

gem install mimemagic -v '0.3.9' --source 'https://rubygems.org/' をしろと言っているので、実行してみると今度はさらに以下のエラーが発生した。

ERROR:  Error installing mimemagic:
ERROR: Failed to build gem native extension.

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.

どうやら以下のサイトの事象だった。
このエラーが発生したのが、2021年03月26日時点

[RailsのGPL混入問題についてまとめ]

この記事を参考に  "shared-mime-info" をインストールしたが、
自分のmacの問題で途中でエラーとなる
$ brew install shared-mime-info

.....

Error: Your CLT does not support macOS 11.
It is either outdated or was modified.
Please update your CLT or delete it if no updates are available.
Update them from Software Update in System Preferences or run:
  softwareupdate --all --install --force

If that doesn't show you any updates, run:
  sudo rm -rf /Library/Developer/CommandLineTools
  sudo xcode-select --install

Alternatively, manually download them from:
  https://developer.apple.com/download/more/.

Error: An exception occurred within a child process:
  SystemExit: exit

どうやらMacのXcodeのコマンドラインツールの問題らしいので上記のエラー表記の通りに一度削除してから
入れ直したら無事にインストールできた

$ sudo rm -rf /Library/Developer/CommandLineTools
$ sudo xcode-select --install

そこから bundle install をしたら無事にherokuにdeployできた
どうやら "mimemagic" の最新版を入れられれば問題はなさそうだ。


Back