0

I recently installed a version of Ruby (and RubyGems) via homebrew on my Mac because the RubyGems that comes installed on Mac doesn't let you install gems due to permissions issues. I followed the instructions in the top answer in this thread: You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory. (mac user)

After installing some gems, I realized that I don't need this version of Ruby and RubyGems anymore, so I ran brew uninstall ruby to get rid of them (I assume RubyGems gets deleted along with Ruby). However, I checked and it appears the gems I had installed are still in /usr/local/lib/ruby/gems/2.7.0. Can I just delete the usr/local/lib/ruby folder, and is this the correct way of going about it? I don't know if the default RubyGems that comes with MacOS uses this folder.

Tom T
  • 314
  • 2
  • 12

3 Answers3

0

Basically when you run rbenv versions it will display all your ruby versions including the one installed by default (system).

  • system ruby usually located in /usr/local/lib/ruby/gems/2.5.1
  • rbenv ruby default location is inside user path ~/.rbenv/versions/2.5.1/gems

to uninstall ruby using rbenv you need to remove the specific version e.g rbenv uninstall 2.5.1

I suggest that you leave your ruby system installation, but you can remove all the gems inside the ruby system path manually /usr/local/lib/ruby/gems/2.5.1.

kubido
  • 546
  • 6
  • 11
0

I'm the author of that top post in the link you mentioned. You are correct that Homebrew installs gems in /usr/local/lib/ruby/gems/2.7.0. You can confirm that in two ways:

By default, binaries installed by gem will be placed into:
  /usr/local/lib/ruby/gems/2.7.0/bin

You may want to add this to your PATH.

I wrote about this in the Homebrew section of my definitive guide to installing Ruby gems on a Mac.

The system Ruby is NOT installed in /usr/local/lib/ruby. It is in /Library/Ruby/Gems/2.6.0. You can safely remove the /usr/local/lib/ruby directory. On a fresh macOS installation, the /usr/local directory is empty.

You can then check if Homebrew is still healthy by running brew doctor.

monfresh
  • 7,974
  • 1
  • 25
  • 22
0

/usr/local/lib/ruby/gems/2.7.0 used to be brew default install path. Now they have changed it to /opt/homebrew/lib/ruby/gems/2.7.0. So you can delete the previous folder under /usr without a problem.

Pedro Góes
  • 722
  • 6
  • 19