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

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

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

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

Q&A

2回答

3231閲覧

gem install mimemagicが出来ず、rails sまでできない。

monnmomo

総合スコア3

Ruby on Rails

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

0グッド

0クリップ

投稿2021/08/30 14:47

編集2021/08/30 15:05

元々ubuntuで動かしていたrailsアプリをgit cloneして、windowsで動かそうとしました。
しかしrails sで以下のエラーが出ました。

>rails s Could not find gem 'tzinfo-data x64-mingw32' in any of the gem sources listed in your Gemfile. Run `bundle install` to install missing gems.

そこで言う通りbundle installすると以下のようになります。

~省略~ Fetching mimemagic 0.3.7 Installing mimemagic 0.3.7 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mimemagic-0.3.7/ext/mimemagic C:/Ruby27-x64/bin/ruby.exe -IC:/Ruby27-x64/lib/ruby/2.7.0/rubygems -rrubygems C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.3/exe/rake RUBYARCHDIR\=C:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/mimemagic-0.3.7 RUBYLIBDIR\=C:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/mimemagic-0.3.7 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-types 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 C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mimemagic-0.3.7 for inspection. Results logged to C:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/mimemagic-0.3.7/gem_make.out An error occurred while installing mimemagic (0.3.7), and Bundler cannot continue. Make sure that `gem install mimemagic -v '0.3.7' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: mimemagic

さらにいう通りgem install mimemagic -v '0.3.7'をするとこのようになります。

>gem install mimemagic -v '0.3.7' --source 'https://rubygems.org/' Temporarily enhancing PATH for MSYS/MINGW... Building native extensions. This could take a while... ERROR: Error installing mimemagic: ERROR: Failed to build gem native extension. current directory: C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mimemagic-0.3.7/ext/mimemagic C:/Ruby27-x64/bin/ruby.exe -IC:/Ruby27-x64/lib/ruby/2.7.0/rubygems -rrubygems C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/rake-13.0.3/exe/rake RUBYARCHDIR\=C:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/mimemagic-0.3.7 RUBYLIBDIR\=C:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/mimemagic-0.3.7 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-types 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)

何をすればよいかわからず困っています・・・お助けいただければ幸いです。

環境とプロジェクトのrubyのバージョン差は、rails sした際エラーがでたので解消してあります。(ruby '2.7.4')
railsのバージョン差は特にエラーが出なかったので放置しています。
(プロジェクトは'rails', '~> 5.2.4', '>= 5.2.4.5'、環境の方は「rails -v」を打つと「rails s」を打った時と同じエラーが出て確認できませんでしたが、最新のバージョンだったと思います。)
昨日まではrails -vでエラー出なかった気がするのですが、今日はなぜかrailsコマンドでエラーが出ます。

windowsの環境構築はこちらのリンクの手順で行いました。
https://qiita.com/AoiLaurent/items/0b3b5f41fbd143bfa563

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

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

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

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

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

guest

回答2

0

これまでも同じ質問をされている方が多すぎるので、GoogleかTeratail内を検索してから質問しましょう。

https://hackmd.io/@mametter/mimemagic-info-ja

(2021/03/27現在)Rails 5.2.5 / 6.0.3.6 / 6.1.3.1 はmimemagicに依存しなくなりました。これらにバージョンアップしましょう。

投稿2021/08/30 15:43

mather

総合スコア6753

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

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

0

windowsでRails環境を作る場合、まずやってはいけない事は直接Windowsで環境構築をする事です。
具体的にはWidows版のRubyを使う事です。
RubyIntallerとか。
今回C:/Ruby27-x64というパスになってますので、Windows版のRubyを使っていますね。
これはやってはダメなパターンです。
無理にWindowsで頑張っても必ずgemのインストールでつまづきます。

回避策は、

  • vagrant+VirtualBox+Linux(UbuntuまたはCentOS)
  • Docker
  • WSL2(ubuntu)

のいずれかでLinux環境を構築してその上でRuby/Railsの開発環境を構築する事になります。

投稿2021/08/30 15:41

mingos

総合スコア4032

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

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

ただいまの回答率
85.46%

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

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

質問する

関連した質問