How to install a beta version of Rails

This article will show you how using the gem command you can install beta versions of Rails

Eager to try out Rails 6 but don’t know how to start a new project with it? This short guide will help.

When you run gem install foo Ruby will install the latest stable version of the gem. Normally this is exactly what you want.

If you want to play with an alpha or beta version of a gem, you need to add some extra information.

Just give me the absolute newest thing

If you want to blindly install the very latest version of the gem, which in this case we do. Then you can run gem install rails --prerelease.

Command line tools like gem use what we call flags to set specific options when calling the tool.

The --prerelease flag tells gem install to install the latest version of the gem, regardless of stable status.

The rest of the article assumes you want to play with a prerelease version, but still have some control over the exact version you want.

Enter the version flag

gem install comes with a whole host of interesting flags. You can find out more about them by typing gem install --help into your console. (side note: --help is a really common flag that lots of tools use to show the help page).

The flag we’re interested in is the version flag. Which is --version or can be abbreviated to just -v.

When we pass --version to the gem install command we can specify an exact version of a gem to install. In our case we want the beta version of Rails.

Finding out the latest version of a gem

The easiest way to find out the versions that are available for you to install is to visit rubygems.org and search for the gem you want the information for.

If you don’t want to leave the command line, you can do it with just the gem tool as well.

gem list rails --remote --prerelease -e is the command I would run to list all of the prerelease versions of Rails.

Using the --remote flag tells gem to look over at rubygems.org instead of just looking at which gems I have installed locally.

Without the --prerelease flag I would just see the latest official version.

Because rails is such a common gem name ( something_rails rails_blah) I also had to pass in -e which stands for exact.

6.0.0.beta1

At the time of writing this article, the latest version of Rails is 6.0.0.beta1.

This is what we can pass into our gem install command, giving us:

gem install rails --version 6.0.0.beta1

Checking which version of Rails you are about to use

You will almost certainly have at least one other version of Rails installed for a specific version of Ruby. If you want to double check which version of Rails is going to run when you type rails new my_awesome_project you can!

The command gem which rails will tell you exactly where the rails app lives, part of that information includes the version.


Recent posts View all

Freelancing

Why we have ads

We run ads on the site, this article talks about how we try and make them not terrible and why we monetise in the first place

Accessibility

Writing accessible hashtags

Write accessible hashtags by camel casing them. Because ThisReadsBetter thanthisdoes.