Skip to content

Instantly share code, notes, and snippets.

@tiagoamaro
Last active August 29, 2015 14:19
Show Gist options
  • Select an option

  • Save tiagoamaro/6f39c056f57c5b75e801 to your computer and use it in GitHub Desktop.

Select an option

Save tiagoamaro/6f39c056f57c5b75e801 to your computer and use it in GitHub Desktop.
Shell Script to globally install gems for all Rubies in a RVM installation
GEM_NAME=nokogiri GEM_VERSION=1.6.6.2 ./globally_install_gems.sh & GEM_NAME=nokogiri GEM_VERSION=1.6.6.1 ./globally_install_gems.sh & GEM_NAME=nokogiri GEM_VERSION=1.6.5 ./globally_install_gems.sh & GEM_NAME=nokogiri GEM_VERSION=1.6.4.1 ./globally_install_gems.sh & GEM_NAME=nokogiri GEM_VERSION=1.6.4 ./globally_install_gems.sh &
#!/bin/bash
# Created by Tiago Amaro, 2015
# MIT License http://opensource.org/licenses/MIT
# Usage:
# GEM_NAME=json GEM_VERSION=1.8.2 ./globally_install_gems.sh
GEM_VERSION=${GEM_VERSION:="1.6.6.2"}
GEM_NAME=${GEM_NAME:="nokogiri"}
RUBY_VERSIONS=`rvm list strings`
for RUBY_VERSION in $RUBY_VERSIONS; do
IS_GEM_INSTALLED=`rvm $RUBY_VERSION@global do gem list $GEM_NAME -i --version=$GEM_VERSION`
if ! $IS_GEM_INSTALLED
then
echo "Installing $GEM_NAME $GEM_VERSION in Ruby $RUBY_VERSION global gemset"
rvm $RUBY_VERSION@global do gem install $GEM_NAME --version=$GEM_VERSION --no-ri --no-rdoc &
else
echo "GEM $GEM_VERSION is already globally installed for $RUBY_VERSION"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment