Skip to content

Instantly share code, notes, and snippets.

@wlads
Last active February 21, 2023 17:49
Show Gist options
  • Save wlads/8e3690512b7cf95d487d5425acb083f4 to your computer and use it in GitHub Desktop.
Save wlads/8e3690512b7cf95d487d5425acb083f4 to your computer and use it in GitHub Desktop.
[sh] Check if a ruby gem is installed
# gem list -i -e 'debug' -v '>= 1.0.0'
# -i returns true / false
# -e exact match (avoid partial match), could also be a regex e.g. '^debug$'
# -v specify gem version (may also use pessimistic version)
function check_ruby_debug() {
debug_gem_installed=$(gem list -i -e "debug" -v ">= 1.0.0")
if [[ $debug_gem_installed = "false" ]]; then
echo -e "Ruby's debug gem not installed!"
echo -e "run: gem install debug"
exit 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment