The official ruby snap is available

We released the official snap package of Ruby language.

https://snapcraft.io/ruby

Snap is a package system developed by Canonical. It allows you to distribute a software with its dependencies for many different Linux systems. This solves the problem that a user cannot install the latest Ruby release from the default repository of their system like in rpm or apt.

On Ubuntu 16.04 or later, you can use Ruby snap with the following command:

sudo snap install ruby --classic

(If you use other Linux distributions, please refer to https://docs.snapcraft.io/installing-snapd/6735)

Our snap uses the “channel” feature to release multiple Ruby series concurrently. For example, without specifying a channel, 2.5.3 will be installed. But if you want to use Ruby 2.4, specify the 2.4 channel like the following:

sudo snap install ruby --classic --channel=2.4/stable

You can also use multiple channels. The following commands switch to Ruby 2.3:

sudo snap switch ruby --channel=2.3/stable
sudo snap refresh

Our snap set $HOME/.gem to GEM_HOME and GEM_PATH environment variable. So if you want to execute commands installed by rubygems such as rails and rspec without using bundle exec, you have to add the following line to your shell rc files (like .bashrc):

eval `ruby.env`

Since $HOME/.gem is shared by multiple versions, if you switch versions and use them, you will need to recompile C extensions using the gem pristine --extensions command.

The initial version of official Ruby snap has released during Snapcraft summit held at Canonical office in London on Nov 6-8th, 2018. Any feedbacks are welcomed at https://github.com/ruby/snap.ruby.

Enjoy!