gem
Manage RubyGems packages
TLDR
Search for remote gem(s) and show all available versions
Install the latest version of a gem
Install a specific version of a gem
Install the latest matching (SemVer) version of a gem
Update a gem
List all local gems
Uninstall a gem
Uninstall a specific version of a gem
SYNOPSIS
gem [options] <command> [arguments]
PARAMETERS
-v, --version
Show gem program version.
-h, --help [COMMAND]
Show help on the gem command or a specific subcommand.
-t, --[no-]trust-policy POLICY
Specify gem trust policy (e.g., 'trust-policy LowSecurity').
-I, --[no-]include-dependencies
Include gem dependencies in operations (e.g., uninstall).
-E, --[no-]env-shebang
Rewrite executables with an environment shebang (#!).
-V, --verbose
Enable verbose output.
-q, --quiet
Suppress output.
-s, --source URL
Specify a gem source URL. Can be specified multiple times.
-u, --[no-]update-sources
Update gem sources (only during install/update).
-n, --no-document
Disable generation of documentation.
-N, --no-user-install
Disable user gem installation.
-w, --[no-]wrappers
Generate wrappers for executables.
--[no-]build-args ARGS
Specify build arguments for gem compilation.
--[no-]format-executable
Make installed executables compatible with environments that only execute files ending in .exe
--[no-]ignore-dependencies
Ignore specified dependencies.
--[no-]prerelease
Allow prerelease gems.
--[no-]development
Include development dependencies.
--[no-]user-install
Do not install to user's home directory
DESCRIPTION
The gem command is the primary interface for interacting with RubyGems, the Ruby package manager. It allows you to install, uninstall, update, and manage Ruby packages (gems). Gems are self-contained libraries or applications that can be easily distributed and reused. The gem command provides a rich set of options to control various aspects of gem management, including specifying gem sources, resolving dependencies, and managing gem versions.
Using gem, developers can easily leverage existing libraries and tools, promoting code reuse and speeding up development cycles. It is an essential tool for any Ruby developer, enabling efficient management of project dependencies and access to a vast ecosystem of open-source libraries. A gem is essentially an archive file that contains Ruby code, documentation, and metadata.
CAVEATS
Requires Ruby to be installed. The availability and functionality of specific commands may vary depending on the RubyGems version installed. Network access is required for installing gems from remote sources.
COMMON SUBCOMMANDS
Some commonly used subcommands include install (to install a gem), uninstall (to remove a gem), update (to update gems), list (to list installed gems), and search (to search for gems on remote repositories).
For example:
gem install rails installs the 'rails' gem.
gem list lists all installed gems.
GEM SOURCES
Gem sources are URLs from which gems can be downloaded. The default source is https://rubygems.org. You can add or remove sources using `gem source -a
SECURITY
Gems can be digitally signed to verify their authenticity and integrity. RubyGems supports trust policies to control the level of trust placed in gems from different sources. Ensure to properly configure sources to avoid security issues.
HISTORY
RubyGems was initially developed by Chad Fowler and Rich Kilmer, and was first released in 2003. It has evolved since, becoming the standard package manager for Ruby, heavily influenced by CPAN. The gem command is the primary tool used to manage these gems, allowing Ruby developers to easily share, distribute, and reuse code across projects.
SEE ALSO
ruby(1)