Ruby

From Gentoo Wiki
Jump to: navigation, search

Ruby is an interpreted programming language. An implementation of the Ruby interpreter is required for software like Rails, passenger, and GitLab.

Installation

USE flags

USE flags for dev-lang/ruby An object-oriented scripting language

berkdb Add support for sys-libs/db (Berkeley DB for MySQL) global
debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces global
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally global
examples Install examples, usually source code global
gdbm Add support for sys-libs/gdbm (GNU database libraries) global
ipv6 Add support for IP version 6 global
jemalloc Use dev-libs/jemalloc for memory allocation. local
libressl Use dev-libs/libressl as SSL provider (might need ssl USE flag), packages should not depend on this USE flag global
rdoc Install dev-ruby/rdoc after installing Ruby. local
rubytests Install ruby tests that can only be run after ruby is installed local
socks5 Add support for the socks5 proxy global
ssl Add support for Secure Socket Layer connections global
static-libs Build static versions of dynamic libraries as well global
tk Add support for Tk GUI toolkit global
xemacs Add support for XEmacs global

Emerge

Emerge the base package:

root #emerge --ask dev-lang/ruby
Note
Adding the base package in this way will pull it into the system's @world set. Those who are not developing Ruby packages or have some clear and explicit reason for directly emerging the package should gather additional information before proceeding.

Adding a new implementation

To add a new implementation, first adjust the Ruby target variable in /etc/portage/make.conf. For example, if upgrading from Ruby 2.2 to Ruby 2.4, add ruby24 to the RUBY_TARGETS variable:

FILE /etc/portage/make.conf
# 2016-12-12 upgrade from ruby22 to ruby24 -Larry
# RUBY_TARGETS="ruby22"
RUBY_TARGETS="ruby22 ruby24"

Next perform an upgrade of the Ruby base package:

root #emerge --ask dev-lang/ruby

List then select the newly installed implementation using eselect:

root #eselect ruby list
Available Ruby profiles:
  [1]   ruby22 *
  [2]   ruby24 (with Rubygems)
root #eselect ruby set ruby24
Successfully switched to profile:
  ruby24

Finally, update the rest of the packages on the system. This will avoid certain bugs[1] that require the newly emerged Ruby implementation to be selected before upgrading. It will force all packages that depend on the Ruby base package to rebuild by the newly emerge Ruby 2.4 implementation:

root #emerge --ask --update --deep --newuse @world

To remove the older but still installed Ruby 2.2 implementation see the Removal section below.

Installing a test implementation

Starting with Ruby 2.2 the Gentoo Ruby project is using the stable mask mechanism to keep new Ruby implementations marked as testing until they is ready to be unmasked. To use ruby24 on an otherwise stable system, apply the following changes:

FILE /etc/portage/profile/use.stable.maskUnmasking flags for Ruby 2.4
-ruby_targets_ruby24

For further information please see the similar instructions for Python.

Configuration

make.conf

Activate a specific Ruby implementations by adding RUBY_TARGETS="$implementation" to /etc/portage/make.conf. Please note: setting the RUBY_TARGETS variable may overwrite the implementations set by the systems base profile.

FILE /etc/portage/make.conf
RUBY_TARGETS="ruby21 ruby22 ruby23 ruby24"

Multiple Ruby implementations in can be installed in parallel. The RUBY_TARGETS variable picks the implementations from USE_RUBY (which is set ebuilds depending on Ruby) and (re)compiles packages with support for each selected implementation.

Select a Ruby slot with eselect

Ruby is slotted in Portage, to view which installed version slot the system is currently using, run:

root #eselect ruby list

To change the selected slot, issue:

root #eselect ruby set ruby23

Removal

Removing an old implementation

To remove an old implementation, in this case Ruby 2.2, first be certain Ruby as been updated (see the Adding a new implementation section). A newer implementation of Ruby will need to be installed before an older implementation can be removed. This is to ensure the packages that depend on Ruby will have an interpreter to run them.

After the new implementation has been selected, remove the old implementation from the RUBY_TARGETS variable:

FILE /etc/portage/make.confRemoving the Ruby 2.2 implementation
# RUBY_TARGETS="ruby22 ruby23" # 2017-01-01 removed ruby22 -Larry
RUBY_TARGETS="ruby23"

It is safe not to add and remove targets to the RUBY_TARGETS variable in one step.

Next, ask Portage to rebuild the @world set with the new Ruby target list:

root #emerge --ask --update --deep --newuse @world

After the emerge completes, update the slot to the newly installed version (2.3 in this case) using eselect as mentioned above.

Finally, as long as no packages are still using the old version, it should be removable by asking Portage to do a dependency clean:

root #emerge --depclean

See also

  • Python - An interpreted, interactive, object-oriented programming language. Without Python Gentoo would not be Gentoo.
  • The Ruby Project page

External resources

References

  1. https://bugs.gentoo.org/628838