Last Updated: February 25, 2016
·
624
· ksi

Auto install gems on new ruby version with rvm

Every once in a while you need to install a new ruby version. Using rvm this is fairly simple. However, after that, some essential gems are missing. To automatically install a predefined list of gems, add an rvm hook.

Add a file in ~/.rvm/hooks/. I name it after_install_install_gems and make it executable. This might be the content:

#!/usr/bin/env bash
gems=(
  cocoapods
  tmuxinator
)
for gem in ${gems[@]}; do
  ${rvm_ruby_gem_home}/wrappers/gem install $gem
done

It will install all the gems in the list for the newly installed ruby version.