This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.
Please visit our production wiki at https://wiki.gentoo.org
Ruby
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
+ssl
|
Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security) |
berkdb
|
Add support for sys-libs/db (Berkeley DB) |
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 |
doc
|
Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally |
examples
|
Install examples, usually source code |
gdbm
|
Add support for sys-libs/gdbm (GNU database libraries) |
ipv6
|
Add support for IP version 6 |
jemalloc
|
Use dev-libs/jemalloc for memory management |
jit
|
Enable just-in-time compilation for improved performance. May prevent use of some PaX memory protection features in Gentoo Hardened. |
socks5
|
Add support for the socks5 proxy |
static-libs
|
Build static versions of dynamic libraries as well |
systemtap
|
Enable SystemTap/DTrace tracing |
tk
|
Add support for Tk GUI toolkit |
valgrind
|
Enable annotations for accuracy. May slow down runtime slightly. Safe to use even if not currently using dev-debug/valgrind |
xemacs
|
Add support for XEmacs |
Emerge
Emerge the base package:
root #
emerge --ask dev-lang/ruby
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:
/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 --oneshot --update 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 and support the Ruby 2.4 base implementation to rebuild:
root #
emerge --ask --update --deep --newuse @world
Once the new implementation is emerged and all packages rebuild depending on it are rebuilt, the older Ruby 2.2 implementation can be removed (uninstalled). For removal instructions 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:
/etc/portage/profile/use.stable.mask
Unmasking 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.
/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 has 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:
/etc/portage/make.conf
Removing 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