How to install a Ruby Gem without Root on a Mac
Gems are little packaged Ruby applications that allow you to extend the ecosystem and reuse countless online sources.
If you don’t have Root on your Mac (work at a large company?) but you still want to use a Gem or two, then you will usually get the following error when attempting to install:
This is incredible annoying, but something you can’t avoid. So better find a workaround and move on!
Luckily there is a very easy workaround and it includes changing the global path for the Ruby Gems directory for your user.
Open ~/.bash_profile or ~/.bashrc (whichever one you use and prefer) and add in:
|
|
This clearly means you will need to make sure that path exists, so:
Now source your changed bash file like so:
|
|
(..or ~/bashrc, whichever you originally used)
Sidenote: Did you know instead of using source, you can simply replace it with a dot?
|
|
Now you can install Gems!
|
|
In our example above, we appended the command with –verbose to see how it goes while it’s executing. This is commonly done whenever you’ve experienced an issue and would like to see more the next time around.
If you get SSL errors as follows:
An easy workaround to this is to append –source http://rubygems.org to the end of the gem command; this will tell it to go and grab the dependencies from the non SSL version of the site.
|
|
Disabling SSL is not considered a “solution” but rather a workaround, but please make sure that you trust the source, otherwise it is a sure fine way to get malware and other unknown packages installed on your system.