Rubygems cheatsheet
18 Feb 2023 - Long Ly
A quick reference to common rubygems CLI commands.
Building & publishing
gem build *.gemspec # Build a gem
gem install *.gem # Install locally
gem push *.gem # Upload to rubygems.org
gem yank -v VERSION [-p PLATFORM] # Take it back
gem owner GEMNAME -a new_owner@owner.test # Add new owner
gem owner GEMNAME -r old_owner@owner.test # Remove an owner
Querying & installing
gem install GEMNAME -v VERSION # Install from rubygems.org
gem install GEMNAME -v '>= 0.14.0, < 0.14.4' # Install from rubygems.org
gem uninstall GEMNAME # Uninstall a gem
gem list # List local gems
gem which rake # Point to where lib/rake.rb is
gem search -r rails # [remote] Search for gems
Opening a gem
# https://github.com/fnando/gem-open
gem open GEMNAME
GEM_EDITOR="vim" gem open GEMNAME
Changing to a directory
cd $(dirname `gem which rake`) # Go to a gem's path
Hope this helps and save time for you.