I have never had a default installation of Ruby gems on Mac OS X let me simply
install new gems without requiring
sudo. If you would like to install Ruby gems
sudo, do the following:
GEM_HOMEto your .bash_profile
nano ~/.bash_profileand add
export GEM_HOME=/Users/Michael/.gemwhere the path is to your own Home folder
Add the gem executables to your system path
Also in .bash_profile, add
For some reason these simple steps don’t show up in the top StackOverflow answers.
People often suggest using rvm to install a custom Ruby version that won’t require using
sudo when installing gems or something like rbenv to create a Ruby environment for the
same benefit. If you simply want to use the default installed Ruby version on Mac OS X
(this works in El Capitan) without requiring
sudo, this should do it.