6

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]
Vadim Kotov
  • 7,766
  • 8
  • 46
  • 61
jackxujh
  • 893
  • 9
  • 29
  • Your user may not have proper permissions... Did you try `sudo` ? – Richard Barber Oct 17 '19 at 13:05
  • 1
    @RichardBarber I purposefully did not use `sudo`, because what I am installing should not have root access when executing. – jackxujh Oct 17 '19 at 15:31
  • Installing with `sudo` doesn’t give the executable root permissions. Calling the executable with `sudo` does that. Installing with `sudo` gives the installer permission to install it in whatever dir for which you don’t have proper permissions set. `sudo` your install or repair permissions. – Richard Barber Oct 17 '19 at 15:40
  • 1
    @RichardBarber thanks for clarification on that. Another thing is that, I believe `/Library/` is now a protected directory by the OS. I don't feel `travis` should go so far that I need to disable SIP to install. – jackxujh Oct 17 '19 at 15:43
  • Yes it is protected. I usually install stuff to the /usr/local or /opt/local areas. – Richard Barber Oct 17 '19 at 15:46
  • yes, so I guess what I can do is to install to user location, but unfortunately `--user-install` does not work. – jackxujh Oct 17 '19 at 15:48
  • 1
    Install RVM with `\curl -sSL https://get.rvm.io | bash -s stable`; restart your shell; install Ruby with `rvm install 2.6.0`. [Don't](https://robots.thoughtbot.com/psa-do-not-use-system-ruby) [use](https://chrisherring.co/posts/why-you-shouldn-t-use-the-system-ruby) [system Ruby](http://billpatrianakos.me/blog/2014/05/15/never-use-system-ruby-ever/). – anothermh Oct 17 '19 at 16:30

1 Answers1

3

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.

ACosta
  • 61
  • 1
  • 5