19
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Railsチュートリアルで早速Railsがインストールできなかった話

Last updated at Posted at 2021-05-07

背景

Railsのチュートリアルをチュートリアル通り進めると、早速Railsのインストールでエラーが出たので、対処法。

実行したコマンド

gem install rails -v 6.0.3

エラーの内容

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

    current directory: /Users/tomoki.katsu/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/mimemagic-0.3.10/ext/mimemagic
/Users/tomoki.katsu/.rbenv/versions/2.6.0/bin/ruby -rrubygems /Users/tomoki.katsu/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rake-12.3.2/exe/rake RUBYARCHDIR\=/Users/tomoki.katsu/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/mimemagic-0.3.10 RUBYLIBDIR\=/Users/tomoki.katsu/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/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.

The FREEDESKTOP_PLACEHOLDER option is meant as a transitional feature, and will be deprecated in
the next release.

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

rake failed, exit code 1

Gem files will remain installed in /Users/tomoki.katsu/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/mimemagic-0.3.10 for inspection.
Results logged to /Users/tomoki.katsu/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/mimemagic-0.3.10/gem_make.out

調べてみるとどうやら、shared-mime-infoをインストールするか、インストールするRailsのバージョンを変更する必要があるみたい

解決方法

解決方法は以下2通り

インストールするバージョンを変更

Rails 5.2.5 / 6.0.3.6 / 6.1.3.1をインストールする

shared-mime-infoをインストールする

下記コマンドでshared-mime-infoをインストールします。

brew install shared-mime-info

参考記事

19
11
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
19
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?