DEV Community

Corey Schaf
Corey Schaf

Posted on

2 1

Getting Started with Ruby and RVM

As of this writing we will be using ruby 2.5.1. I am going to be walking you through how to set up our basic ruby environment using RVM and how we can easily switch between different ruby installations.

Installing RVM

RVM is a ruby environment manager. This is an optional step in starting ruby development, but highly recommended. This will allow us to have clean ruby environments for each of our projects, regardless of version/dependencies etc.

Running the following cURL command will update our system with the latest stable RVM build.

$> \curl -sSL https://get.rvm.io | bash -s stable --ruby

RVM can show us all the available ruby versions that we can install on our system, from beta to stable to obsolete. Its an amazing way to handle switching different environments with ease. As of this post, the ruby install version is 2.5.1, so that is what we will be working with.

Now we want to run the rvm helper script, that will adjust our RVM installation and our path. This allows us to run rvm at the command line.

> source /Users/corey/.rvm/scripts/rvm

> ruby -v
ruby 2.5.1.p57

This will tell us our current ruby version, which for this example is sitting at ruby 2.5.1p57

Now lets create a gemset, which is a unique environment that will house all our dependencies and gems.

> rvm gemset create rails-test-api
ruby-2.5.1 - #gemset created /Users/coreyschaf/.rvm/gems/ruby-2.5.1@rails-test-api
ruby-2.5.1 - #generating rails-test-api wrappers.......

Now lets switch to our newly created gemset

> rvm gemset use rails-test-api
Using ruby-2.5.1 with gemset rails-test-api

> rvm gemset name
rails-test-api

We are now using our newly created ruby environment. We will install some basic dependencies that we need going forward.

> gem install bundler
fetching: bundler-1.16.5.gem (100%)
Successfully installed bundler-1.16.5
Parsing documentation for bundler-1.16.5
Installing ri documentation for bundler-1.16.5

This installs bundler, which we will be using in our rails install in the next tutorial.

> gem install rails
....
...

> rails --version
Rails 5.2.1

We have successfully installed our development environment and installed the newest Ruby on Rails framework.
Let's create a quick dummy Rails application just to test our install.

> rails new demo-test
Installing ....

> rails s
=> Booting Puma ..
....

Now if we go to our browser, and navigate to localhost:3000 we should see:

Alt Text

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs