Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't Install Rails on Mac OS Catalina

Tags:

I'm getting an error message that I can't find the solution for when I'm trying to install Rails v 6.1.1 on my new Mac machine (still on Catalina, not Big Sur)

I have rbenv and Homebrew installed and have updated to the latest version of Ruby (3.0.0). When I put out which ruby I get: /usr/local/opt/ruby/bin/ruby

Here's the error code I'm seeing in terminal when I run gem install rails -v 6.1.1 (same error with sudo install):

 Building native extensions. This could take a while...  ERROR:  Error installing rails:     ERROR: Failed to build gem native extension.   current directory: /usr/local/lib/ruby/gems/3.0.0/gems/mimemagic-0.3.10/ext/mimemagic  /usr/local/opt/ruby/bin/ruby -I/usr/local/lib/ruby/site_ruby/3.0.0 -rrubygems /usr/local/Cellar/ruby/3.0.0_1/lib/ruby/gems/3.0.0/gems/rake-13.0.3/exe/rake RUBYARCHDIR\=/usr/local/lib/ruby/gems/3.0.0/extensions/x86_64-darwin-19/3.0.0/mimemagic-0.3.10 RUBYLIBDIR\=/usr/local/lib/ruby/gems/3.0.0/extensions/x86_64-darwin-19/3.0.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.  /usr/local/lib/ruby/gems/3.0.0/gems/mimemagic-0.3.10/ext/mimemagic/Rakefile:15:in `locate_mime_database'  /usr/local/lib/ruby/gems/3.0.0/gems/mimemagic-0.3.10/ext/mimemagic/Rakefile:39:in `block in <top (required)>'  Tasks: TOP => default  (See full trace by running task with --trace)   rake failed, exit code 1   Gem files will remain installed in /usr/local/lib/ruby/gems/3.0.0/gems/mimemagic-0.3.10 for inspection.  Results logged to /usr/local/lib/ruby/gems/3.0.0/extensions/x86_64-darwin-19/3.0.0/mimemagic-0.3.10/gem_make.out 
like image 432
Laura Thorson Avatar asked Mar 26 '21 20:03

Laura Thorson


People also ask

Why is Catalina not installing Mac?

Typically, a macOS download fails if you do not have enough storage space available on your Mac. To make sure you do, open up the Apple menu and click on 'About This Mac. ' Select 'Storage' then check to make sure you have enough space on your hard drive. You need at least 15GB free.


2 Answers

If you want to have brew install this for you and you haven't updated brew in a while, I would recommend running:

HOMEBREW_NO_AUTO_UPDATE=1 brew install shared-mime-info 

I ran just

brew install shared-mime-info 

And it updated a bunch of packages I didn't want it to and broke my ruby installation.

I like spickermann's solution too. It seems to be what the package maintainers want you to do.

like image 89
C-RAD Avatar answered Oct 07 '22 19:10

C-RAD


Just install shared-mime-info on your computer. From the docs of the mimemagic gem

You will require a copy of the Freedesktop.org shared-mime-info database to be available. If you're on Linux, it's probably available via your package manager, and will probably be in the location it's being looked for when the gem is installed.

macOS users can install the database via Homebrew with
brew install shared-mime-info.

Should you be unable to use a package manager you can obtain a copy of the needed file by extracting it from the Debian package. This process will also work on a Windows machine. [...]

Or

you might want to consider installing Rails 6.1.3.1 (instead of 6.1.1 in your command). That version was released to fix exactly the mimemagic issue that you are facing – just a couple of hours ago.

like image 45
spickermann Avatar answered Oct 07 '22 19:10

spickermann