rvm
Manage Ruby environments and versions
TLDR
Install one or more versions of Ruby
Display a list of installed versions
Use a specific version of Ruby
Set the default Ruby version
Upgrade a version of Ruby to a new version
Uninstall a version of Ruby and keep its sources
Remove a version of Ruby and its sources
Show specific dependencies for your OS
SYNOPSIS
rvm [options] [command] [arguments]
Example: rvm install ruby-3.1.2
Example: rvm use 2.7.5@my_project --default
PARAMETERS
install
Installs a specific Ruby version (e.g., `ruby-3.1.2`, `jruby`).
use
Switches to a specific Ruby version and optionally a gemset for the current shell session.
list | ls
Lists all installed Ruby versions and available gemsets.
gemset
Manages gemsets. Common subcommands include `create`, `list`, `delete`, `use`, `empty`.
remove
Removes an installed Ruby version and its associated gemsets.
info
Displays detailed information about the current RVM, Ruby, and gemset environment.
--default
Used with `use` to set the specified Ruby/gemset as the default for new shells.
cleanup
Performs various cleanup operations, such as removing old logs or source files.
unuse
Reverts to the system Ruby or the default RVM Ruby.
DESCRIPTION
RVM, or Ruby Version Manager, is a powerful command-line tool designed to help developers install, manage, and work with multiple Ruby environments on a single machine. It allows for the installation, use, and management of various Ruby interpreters (e.g., MRI, JRuby, Rubinius) and their associated gemsets, which are isolated collections of gems. This solves common dependency conflicts between different projects that might require different Ruby versions or specific gem versions.
RVM integrates deeply with the user's shell, typically installing Rubies into the user's home directory, thus avoiding the need for system-wide installations and `sudo` permissions for most operations. It enables developers to easily switch between different Ruby versions and gemsets on a per-project basis, ensuring that each project's dependencies are precisely met without affecting others.
CAVEATS
RVM can be complex for beginners due to its extensive feature set and deep shell integration. It modifies shell startup files, which can sometimes lead to slower shell loading times or conflicts if not managed carefully. While powerful, some users prefer simpler alternatives like `rbenv` or `chruby` for their less intrusive nature. Ensuring proper RVM initialization in the shell environment is crucial for its functionality.
GEMSETS
RVM's gemsets are isolated collections of gems associated with a specific Ruby version. They allow developers to maintain distinct sets of project dependencies, preventing conflicts between different projects using the same Ruby version but different gem requirements. For example, a project using Rails 5 and another using Rails 6 could both use Ruby 2.7 by having separate gemsets.
SHELL INTEGRATION
RVM works by sourcing its initialization script in your shell's configuration file (e.g., `.bashrc`, `.zshrc`). This modifies your shell's `PATH` and other environment variables, enabling RVM to intercept commands like `ruby` and `gem` and direct them to the correct version and gemset. This deep integration is fundamental to its ability to manage multiple Ruby environments seamlessly.
HISTORY
RVM was created by Michal Papis and first released around 2009. It quickly gained widespread adoption in the Ruby community as one of the pioneering and most comprehensive solutions for managing multiple Ruby installations and their dependencies. Prior to RVM, managing different Ruby versions for various projects was a significant challenge, often leading to 'dependency hell.' RVM addressed this by providing robust isolation and easy switching capabilities. While newer, often simpler, alternatives have emerged (like `rbenv`), RVM continues to be actively maintained and used by many developers who appreciate its comprehensive features, particularly its powerful gemset management.