Either using brew, or via rbenv.
To avoid issues with gem installation, configure gem with --no-ri. Here is a sample ~/.gemrc that has some sensible settings:
install: --no-rdoc --no-ri --env-shebang
update: --no-rdoc --no-ri --env-shebang