Ruby gems

From wikinotes

A package manager for ruby libraries.
You may also be interested in the ruby gemfile, and ruby bundler.

Documentation

cli docs https://guides.rubygems.org/command-reference/
homepage/repo https://rubygems.org/
github https://github.com/rubygems/rubygems
gemspec file ref https://guides.rubygems.org/specification-reference/
wikipedia https://en.wikipedia.org/wiki/RubyGems

Environment

GEM_HOME=                # where gems are installed
GEM_PATH=/a/b:/c/d:/e/f  # where gems are found

Notes

ruby gem projects
ruby gem package management

Usage

gem -h
gem list -h                          # help for subcommand

gem search <pkg>                     # search for gem

gem install ${PKG} \
    -v 1.8          `# gem-version (also supports >=, ~>)` \
    --user-install  `# user install (rather than system install)` \
    --platform ruby `# specify platform for compiled gems, or ruby to build from src` \

gem list --local                     # list installed gems/versions
gem list -i ${GEM} -v ${VERSION}     # list installed gems
gem which \*${GEM}\*                 # list install location of gem

gem unpack file.gem # extract gem


If building packages with extensions, you can pass additional commandline arguments. See ruby extensions for more details.

# You may need to issue additional params to ruby
# when building a package. These are passed following '--'
# ex:
#   gem install -- [arguments passed to ruby interp]
gem install -- \
  --with-opt-dir=/opt/lib/package  \ # add directory with subdirs 'include/' and 'lib/' for C headers/libs.

File Structure

gem_name/
  bin/
    gem_name
  lib/
    gem_name.rb
  test/
    test_gem_name.rb
  README
  Rakefile
  gem_name.gemspec