[Ruby on Rails (RoR)] Install Ruby Version Manager (RVM) and try out ruby
Ruby Version Manager (RVM)
RVM is a command-line tool which allows you to easily install, manage, and work with multiple ruby environments from interpreters to sets of gems.
RVM: Ruby Version Manager - RVM Ruby Version Manager - Documentation - https://rvm.io/
Installation explained
There are three different ways to install and configure RVM.
-
Single-User installations (recommended) - For an isolated install within a user’s $HOME, not for root.
-
Multi-User installations - For server administrators - For an installation usable by all users on the system - Please note that Single-User supersedes Multi-User. This also used to be called the System-Wide Install. Using this type of installation without knowledge how umask works is a big security risk.
-
Mixed mode installations - For an installation usable by all users on the system - with isolated rubies/gemsets within a user’s $HOME. Installation instructions are exactly the same as for Multi-User installations, the difference is in users environment.
Install RVM
1. Install GPG keys
As a first step install GPG keys used to verify installation package:
1 | gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB |
In case you encounter an issues check security
2. Install RVM stable version
1 | \curl -sSL https://get.rvm.io | bash -s stable |
Single-User Install Location: ~/.rvm/
If the install script is run as a standard, non-root user, RVM will install into the current users’s home directory.
3. Reload shell configuration & test
Close out your current shell or terminal session and open a new one (preferred). You may load RVM with the following command:
1 | source ~/.rvm/scripts/rvm |
If installation and configuration were successful, RVM should now load whenever you open a new shell. This can be tested by executing the following command which should output rvm is a function as shown below.
1 | type rvm | head -n 1 |
NOTE: Before reporting problems check rvm notes
as it might contain important information.
Congratulations! You have successfully installed RVM.
Try out your new RVM installation
Below are some examples of how to install and use a Ruby under RVM.
Display a list of all known rubies. NOTE: RVM can install many more Rubies not listed.
1 | rvm list known |
Install a version of Ruby (eg 2.1.1):
1 | rvm install 2.1 |
1 | rvm use 2.1 |
1 | ruby -v |
1 | which ruby |
1 | rvm use 2.1 --default |
FAQs
Warning! PATH is not properly set up, /Users/cloudolife/.rvm/gems/ruby-2.6.1/bin is not at first place.
1 | rvm get stable |
With option --auto-dotfiles
to resolve it.
1 | rvm get stable --auto-dotfiles |
Reference
[1] RVM: Ruby Version Manager - RVM Ruby Version Manager - Documentation - https://rvm.io/
[2] RVM: Ruby Version Manager - Installing RVM - https://rvm.io/rvm/install#installation
[3] Ruby Programming Language - https://www.ruby-lang.org/en/