Ramon Suarez Ramon Suarez - 22 days ago 6
Ruby Question

How can I find all ruby gems installed with sudo gem install?

I'm learning to code on ruby and before knowing any better I installed some gems with

sudo gem install name-of-gem
, which is now wreaking havoc with some projects. I've read the gem documentation and have not found a way to show which gems have been installed with
sudo
. How can I do find them?

Answer

If your system comes with a built-in ruby, it (and the gems) are in protected folder. To install gems, you need sudo.

Normally, though, you leave the system ruby alone and install newer version with one of the ruby version switchers (RVM, chruby/ruby-install, rbenv/ruby-build). But before you discovered version switchers, you may have installed some gems with sudo into the system ruby.

If which gem and sudo which gem return different paths (which likely means that under sudo you use system ruby and not your custom one), you can safely uninstall all of the gems you installed with sudo.