6

I wanted to install ruby on rails for windows 10, following the same instructions of this video: https://www.youtube.com/watch?v=G-B_KUFNkQQ

When it finish the installation of ruby, I return to the console and after gem install rails, I get this error:

C:\Users\Usuario>gem install rails --no-document
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
ERROR:  Error installing rails:
        ERROR: Failed to build gem native extension.

    current directory: C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mimemagic-0.3.9/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.1/exe/rake RUBYARCHDIR\=C:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/mimemagic-0.3.9 RUBYLIBDIR\=C:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/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 C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/mimemagic-0.3.9 for inspection.
Results logged to C:/Ruby27-x64/lib/ruby/gems/2.7.0/extensions/x64-mingw32/2.7.0/mimemagic-0.3.9/gem_make.out

I tried to solve making an update and "gem install mime-types-data" but stills with the same problem...

The Ruby Installer is Ruby+Devkit 2.7.2-1 (x64) and my ruby version is ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x64-mingw32]

2
  • Hi, and welcome! I'm not a Windows user so I can't help with the details, but the error message says what to do next: "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." Commented Mar 26, 2021 at 14:24
  • stackoverflow.com/questions/69248078/… Commented Jul 21, 2022 at 13:37

6 Answers 6

14

Windows 10 ruby 2.6.2 install rails 6.0.0.rc1

  1. Download the shared-mime-info from https://gitlab.freedesktop.org/xdg/shared-mime-info/uploads/0440063a2e6823a4b1a6fb2f2af8350f/shared-mime-info-2.0.tar.xz
  2. Extract the downloaded package with 7Zip or WinRAR.
  3. Place it in a location of your choice e.g. "C:\package".
  4. Set a new Environment Variable with a name: FREEDESKTOP_MIME_TYPES_PATH and browse value to the location e.g. C:\shared-mime-info 2.0\data\freedesktop.org.xml.in
  5. Refresh terminal or CMD e.g. Command

refreshenv

  1. And finally, gem install rails -v 6.0.0.rc1
Sign up to request clarification or add additional context in comments.

Comments

6
  • windows 10 ruby : 2.5.8

I downloaded package from https://gitlab.freedesktop.org/xdg/shared-mime-info/ and then set the environment variable (Windows) FREEDESKTOP_MIME_TYPES_PATH to that path ("c:....\data\freedesktop.org.xml.in")

also I installed mime-types-data > gem install mime-types-data

at first it didn't work after closing and opening again the terminal it did.

tip: if you use vscode you need to reopen vscode

  • Mac

If you are using macOS, try the following

brew install shared-mime-info

bundle update mimemagic

Comments

3

the problem is that the mimemagic team yanked a lot of versions yesterday https://rubygems.org/gems/mimemagic/versions now you have to install the package shared-mime-info in your distribution.

I would recommend using WSL for rails development in windows, it will save a lot of problems in the future.

Comments

1

For MacOs or Linux - Install shared-mime-info package to resolve that issue.

macOS

$ brew install shared-mime-info

Debian, Ubuntu

apt-get update && apt-get install -y shared-mime-info

Comments

0

after a quick google search, this seems appropriate:

from MimeMagic Github Page :

This process will also work on a Windows machine.

  1. Download the package from https://packages.debian.org/sid/amd64/shared-mime-info/download

  2. Ensure the command line version of 7-Zip is installed

  3. 7z x -so shared-mime-info_2.0-1_amd64.deb data.tar | 7z e -sidata.tar "./usr/share/mime/packages/freedesktop.org.xml"

Place the file freedesktop.org.xml in an appropriate location, and then set the environment variable FREEDESKTOP_MIME_TYPES_PATH to that path.

Once that has been done the gem should install successfully.

Please note that the gem will depend upon the file remaining in that location at run time.

Comments

0

If you are using MacOS

Error:
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"]

Then below 2 commands acts as a savior.

$ brew install shared-mime-info

$ gem install mimemagic -v '0.3.10' --source 'https://rubygems.org/'
Building native extensions. This could take a while...
Successfully installed mimemagic-0.3.10
Parsing documentation for mimemagic-0.3.10
Installing ri documentation for mimemagic-0.3.10
Done installing documentation for mimemagic after 0 seconds
1 gem installed

Then Run Bundle

$ bundle
$ bundle install

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.