how to install gems without sudo
When you install them without sudo, Ruby doesn't know where they get installed to. I can't remember where it installs them by default, probably somewhere like ~/.gems or something. Anyway, you can tell Ruby that's where they're installed by setting the GEM_HOME environment variable.
$ # assuming your gems are stored in ~/.gems$ GEM_HOME="$HOME/.gems" ruby my_program.rb
If that works, then you might put it in your ~/.bashrc (there are a number of possible files this could go in, depending on your system)
For Mac users, this works for me...
- Add GEM_HOME to your
.bash_profile
For example, nano ~/.bash_profile
and add export GEM_HOME=$HOME/.gem
where the path is to your own Home folder
- Add the gem executables to your system path
Also in .bash_profile
, add export PATH="$GEM_HOME/bin:$PATH"
Source: http://michaelehead.com/2016/02/06/installing-gems-without-sudo.html