Don't run random scripts basically, always check their content. Specially if they require root.
$ cat /etc/gemrc
# --user-install is used to install to $HOME/.gem/ by default since we want to separate
# pacman installed gems and gem installed gems
gem: --user-install