I was getting this error ERROR: While executing gem … (Errno::EPERM) trying to install a gem on OS X El Capitan (10.11.3) even with sudo before. I found a solution changing my GEM paths. I’m using zsh so I had to add two lines to my .zshrc
export GEM_HOME=~/.gems
export PATH=$PATH:~/.gems/bin