it is obvious that /usr/local/rvm is system installation, detect it first before checking $HOME as it is not set on puppet / chef which breaks everything