Macos – You don’t have write permissions for the /Library/Ruby/Gems/2.3.0 directory

bundlemacosrubygems

When I use command gem install bundler in MacOS 10.13.x, the error is:

You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

$ gem install bundler
Fetching: bundler-1.16.2.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

Best Answer

This is basically a duplicate of this question, where I already posted a detailed answer that solves the problem. Instead of maintaining two separate answers, I thought it would be better to just link to my answer here since the same solution applies: https://stackoverflow.com/a/54873916/928191