Handy RVM Commands
I’m learning Ruby! Its fun and today I was exploring RVM. RVM is somewhat like NuGet but for Ruby.
RVM needs to be installed, and you can do so using
\curl -ssl https://get.rvm.io | bash -s stable --ruby
There is a backslash before the curl command this prevents any issues if you may have aliased it with configuration in your ~/.curlrc file.
This command will install both RVM and Ruby, so with this one command your machine will have both Ruby and RVM ready for use.
Great now that you have RVM lets perform some tasks
Want another version of Ruby on your machine?
$ rvm install 2.0.0
What versions of Ruby do you have?
$ rvm list
This will return a list similar to
$ rvm rubies ruby-2.0.0-p195 [ x86_64 ] =* ruby-2.0.0-p481 [ x86_64 ] ruby-2.1.0 [ x86_64 ] # => - current # =* - current && default # * - default
What different versions of Ruby are there in the whole wide world?
$ rvm list known
Here is a small list of what was available for me to download
MRI Rubies [ruby-]1.8.6[-p420] [ruby-]1.8.7[-head] # security released on head [ruby-]1.9.1[-p431] [ruby-]1.9.2[-head] # security released on head [ruby-]1.9.3[-p547] [ruby-]2.0.0-p451 [ruby-]2.0.0[-p481] [ruby-]2.1.1 [ruby-]2.1[.2] [ruby-]2.1-head ruby-head
How do I change the version of Ruby I am currently using? Let’s say you are using 2.0.0-p195 and want to use 2.1.0.
$ rvm use ruby-2.1.0
RVM is updated frequently, to get the latest version run
$ rvm get stable
Gemsets are self-contained collections of gems, this means you can have many of the same gems at different versions and this won’t clash.
To create a gemset just type
$ rvm gemset create some_name
To use this all you need to do is
$ rvm gemset use some_name
What gemsets are available on my machine?
rvm gemset list
Then you can go mad and install your gems! Whats is awesome is that you don’t need to worry about clashes.
I am writing this down because I will forget all this information and need a reference. I am hoping this will help someone someday even if that someone is me!