Skip to content

Instantly share code, notes, and snippets.

@michaelxor
Created October 14, 2015 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelxor/97a57c3e1956ebf40b89 to your computer and use it in GitHub Desktop.
Save michaelxor/97a57c3e1956ebf40b89 to your computer and use it in GitHub Desktop.
#!/bin/bash
GEMSETS=$(find ~/.rvm/gems -maxdepth 1)
VERSION_TO_REMOVE="1.10.6"
for i in ${GEMSETS[@]}
do
GEMSET=${i##*/}
if [[ $GEMSET == "gems" || $GEMSET == "cache" ]]; then
continue
fi
echo $GEMSET
matches=$(bash -lc "rvm use $GEMSET &> /dev/null; gem list | grep '^bundler ($VERSION_TO_REMOVE)$'")
if [[ $? != 0 ]]; then
matches=$(bash -lc "rvm use $GEMSET &> /dev/null; gem list | grep '^bundler.*$VERSION_TO_REMOVE'")
if [[ $? != 0 ]]; then
echo "$GEMSET does not have $VERSION_TO_REMOVE at all"
else
echo $matches
echo "$GEMSET has $VERSION_TO_REMOVE and other versions"
bash -lc "rvm use $GEMSET &> /dev/null; yes | gem uninstall bundler -v $VERSION_TO_REMOVE"
fi
else
echo $matches
echo "$GEMSET has only $VERSION_TO_REMOVE"
fi
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment