Install ruby gems without sudo on OSX
October 4, 2015
Quick guide to install latest version of ruby and avoid using sudo to install ruby gems.
If you encountered the following error when trying to install a ruby gem on MAC OSX, it’s only because of some persmission related to how/where the ruby version that come packed OSX is installed. To fix it, is enough to rely on rbenv, a ruby version manager.
We’ll be using the Z shell (zsh) instead of bash. Replace any reference to .zshrc
with .bash_profile/.bashrc
in case you are running on bash instead.
Install rbenv
We’ll install rbenv via homebrew:
Add the following references to your .zshrc
Install Ruby
Install a more recent ruby version via rbenv
Set the globa version to the latest installed version of ruby, i.e:
To verify if everything installed successfully just run the following commands:
Enjoy! You should now be able to install ruby gems without having to use sudo!