Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install with Gem on macOS Catalina

I was trying to install Travis.rb as documented by the team. However, the location that gem tried to install to is protected by the OS. So I got an error like this:

% gem install travis
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.

I tried the following command but did not fully work - installation was okay, but I could not call % travis.

gem install travis --user-install

Configuration: I am using gem shipped with the OS:

% ruby -v  
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
like image 295
jackxujh Avatar asked Oct 17 '19 08:10

jackxujh


People also ask

What is gem in macOS?

The interface for RubyGems is a command-line tool called gem which can install and manage libraries (the gems). RubyGems integrates with Ruby run-time loader to help find and load installed gems from standardized library folders.

Where are gems installed macOS?

By default, binaries installed by gem will be placed into: /usr/local/lib/ruby/gems/3.1. 0/bin You may want to add this to your PATH.


1 Answers

It is always a good idea to do user installation and avoid system things. Therefore doing...

gem install travis --user-install

... seems to be recommended way.

After that, the executable files are there, but you have to fix you PATH to run by adding your ~/.gem/ruby/2.6.0 folder to the path. See https://guides.rubygems.org/faqs/#user-install on how to do it.

like image 153
ACosta Avatar answered Sep 30 '22 14:09

ACosta