The gems I install via sudo gem install ... can\'t be executed (I get a command not found). They seem to install into /usr/local/Cellar/
sudo gem install ...
command not found
/usr/local/Cellar/
Using the info in Timo's answer, I've got this:
PATH=/usr/local/opt/ruby/bin:$PATH GEMSDIR=$(gem environment gemdir)/bin PATH=$GEMSDIR:$PATH export PATH
Works for Homebrew, works for the separate gems directory, and doesn't hardcode a Ruby version.