Ruby
Ruby is Article description::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) |
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. |
libressl
|
Use dev-libs/libressl instead of dev-libs/openssl when applicable (see also the ssl useflag) |
rdoc
|
Install dev-ruby/rdoc after installing Ruby. |
rubytests
|
Install ruby tests that can only be run after ruby is installed |
socks5
|
Add support for the socks5 proxy |
ssl
|
Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security) |
static-libs
|
Build static versions of dynamic libraries as well |
systemtap
|
Enable SystemTAP/DTrace tracing |
tk
|
Add support for Tk GUI toolkit |
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.5 to Ruby 2.6, add ruby26
to the RUBY_TARGETS variable:
/etc/portage/make.conf
<syntaxhighlight lang="bash"># 2020-04-05 upgrade from ruby 2.5 to ruby 2.6 -Larry # RUBY_TARGETS="ruby25" RUBY_TARGETS="ruby25 ruby26"</syntaxhighlight>
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] ruby25 (with Rubygems) * [2] ruby26 (with Rubygems)
root #
eselect ruby set ruby26
Successfully switched to profile: ruby26
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.6 base implementation to rebuilt:
root #
emerge --ask --update --deep --newuse @world
Once all packages depending on the newly installed implementation have been rebuilt, the older implementation can be unmerged (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 are ready to be unmasked. For example, to use Ruby 2.7 on an otherwise stable system, apply the following changes:
/etc/portage/profile/use.stable.mask
Unmasking flags for Ruby 2.7-ruby_targets_ruby27
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
<syntaxhighlight lang="bash">RUBY_TARGETS="ruby25 ruby26 ruby27"</syntaxhighlight>
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 ruby26
Removal
Removing an old implementation
To remove an old implementation, in this case Ruby 2.4, 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 with which to run.
After the new implementation has been selected, remove the old implementation from the RUBY_TARGETS variable:
/etc/portage/make.conf
Removing the Ruby 2.4 implementation<syntaxhighlight lang="bash"># RUBY_TARGETS="ruby24 ruby25" # 2020-04-05 removed ruby24 -Larry RUBY_TARGETS="ruby25"</syntaxhighlight>
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.4 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