Configuring Ruby

Discover our Public Cloud offer

Shared Hosting for Everyone, imagined by developers, for developers.

Discovering the Public Cloud

Supported Versions (Major Versions)

v2017v2020
-2.7
2.62.6
2.52.5
2.42.4
2.32.3
2.22.2
2.12.1
2.02.0
1.91.9
1.81.8

The default version can be changed from the administration section, under Environment > Ruby. This is the version that is especially used when you start ruby.

Error logs

You can view the error logs in the $HOME/admin/logs/uwsgi/[id].log file where [id] is the identifier for your site, shown in the Web > Sites section.

Binary to use

You need to always use ruby (or /usr/bin/ruby). Never use ruby2.4 or any other command.

To force the use of a different version of Ruby other than the default one, define the environment variable RUBY_VERSION:

$ RUBY_VERSION=2.3 ruby

In your scripts, use /usr/bin/ruby as shebang:

#!/usr/bin/ruby

To force the use of a specific version of Ruby:

#!/usr/bin/eval RUBY_VERSION=2.3 ruby

The other binaries included in Ruby (gem, irb, ri, etc.) work the same way.

Environment

Your Ruby environment starts off empty, with no ready installed libraries other than the standard library.

Installing a package

You can use gem to install packages:

$ gem install rails

Packages are installed in the standard $HOME/.gem directory and they are automatically added to load path by Ruby.

Note that you will need to re-install the packages if you change the major Ruby version (versions 2.3 and 2.4 are two different major versions, whereas 2.3.1 and 2.3.0 use the same major version).

You can specify a specific version:

$ gem install rails -v 4.2

Uninstalling a package

$ gem uninstall rails

Using Bundler

We recommend using Bundler if you use a number of different Ruby applications so that each one has its own separate environment. Bundle installs the packets listed in a Gemfile.

$ bundle install

Rack deployment

So that a Rack application is accessible by the web, you need to add a site in the alwaysdata administration Web > Sites section:

Ruby Rack Site Type
Ruby Rack Site Type
  • type: choose Ruby Rack,
  • application path: the path to your Rack application.

You can also fill-in a number of optional fields:

  • use Bundler,
  • environment variables to define,
  • a specific version of Ruby to use.