After a similar article about Python (List all Gentoo packages built against the old python or specific version) under Gentoo, the Ruby upgrade in Gentoo may have similar problems, so this article shows how to list old Ruby modules and packages build against old ruby environments. Despite a clean upgrade without any blockers or masked packages, sometimes, on old machines, there might be packages left still built against an old version of Ruby, which is no longer available on the system!
On Gentoo, there is one important flag in the configuration make.conf file:
RUBY_TARGETS="ruby30 ruby31"
The RUBY_TARGETS controls the support of multiple Ruby versions installed on the system. When the Gentoo package has a use flag ruby, the builder emerge will build the Ruby module for all the Ruby versions in RUBY_TARGETS.
When building the Gentoo packages expand these variables as USE flags of the kind – ruby_targets_ruby30 and ruby_targets_ruby31. So the user may search for Gentoo installed packages with USE flags ruby_targets_ruby30 and ruby_targets_ruby31 or older like ruby_targets_ruby26, which may be left from previous installations.
For example, to search installed Gentoo packages, which are built against Ruby version 26, search for USE flags ruby_targets_ruby26 using the equerytool from app-portage/gentoolkit.
First, install the equery tool by building the package app-portage/gentoolkit:
emerge -va app-portage/gentoolkit
And then, search for packages with:
root@srv ~ # equery h ruby_targets_ruby26 * Searching for USE flag ruby_targets_ruby26 ... [I--] [??] app-emulation/vagrant-2.2.9-r1:0 [IP-] [ ] app-misc/hivex-1.3.20:0 [IP-] [ ] app-text/htmltidy-5.8.0-r1:0/58 [I--] [??] dev-ruby/listen-1.3.1-r4:1 [I--] [??] dev-ruby/mime-types-2.99.2:2 [IP-] [ ] dev-ruby/net-ssh-5.2.0:5 [IP-] [ ] dev-ruby/net-ssh-6.1.0-r1:6 [IP-] [ ] dev-ruby/rubyzip-1.3.0:1 [I--] [??] dev-ruby/sass-3.5.7-r1:3.5
As shown, there are 9 packages, in which Ruby modules are still built against the old Ruby 26 version, which may not even exist anymore on the system!
It’s worth mentioning, that the above packages may be built not only against one but multiple Ruby versions thanks to multiple versions in Ruby_TARGETS. So the modules above may function properly for the Ruby versions, which are still in use in the system.
All of the above packages should be rebuilt if Ruby 26 is not installed (i.e. it was removed from the system) or is not going to be removed because the user removed it from the RUBY_TARGETS.
Most of the above packages may have newer versions and here is how to check what Ruby version they support:
root@srv ~ # equery u dev-ruby/sass [ Legend : U - final flag setting for installation] [ : I - package is installed with flag ] [ Colors : set, unset ] * Found these USE flags for dev-ruby/sass-3.7.4-r1: U I - - doc : Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally + + ruby_targets_ruby27 : Build with MRI Ruby 2.7.x + + ruby_targets_ruby30 : Build with MRI Ruby 3.0.x + + ruby_targets_ruby31 : Build with MRI Ruby 3.1.x - - test : Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
So the new version of the Ruby module dev-ruby/sass may be built only against Ruby versions 27, 30 and 31.
After the Ruby upgrade in Gentoo always check with equery for modules and packages built against the old Ruby versions.
In some cases, the old packages should be removed from the system, because they are legacy and the new ruby depends on a newer one:
root@srv ~ # emerge -pv --depclean =dev-ruby/sass-3.5.7-r1:3.5 Calculating dependencies... done! >>> Calculating removal order... >>> These are the packages that would be unmerged: dev-ruby/sass selected: 3.5.7-r1 protected: none omitted: 3.7.4-r1 All selected packages: =dev-ruby/sass-3.5.7-r1 >>> 'Selected' packages are slated for removal. >>> 'Protected' and 'omitted' packages will not be removed. Packages installed: 3375 Packages in world: 4740 Packages in system: 49 Required packages: 3374 Number to remove: 1 root@srv ~ # emerge -Cva =dev-ruby/sass-3.5.7-r1:3.5 * This action can remove important packages! In order to be safer, use * `emerge -pv --depclean <atom>` to check for reverse dependencies before * removing packages. >>> These are the packages that would be unmerged: dev-ruby/sass selected: 3.5.7-r1 protected: none omitted: 3.7.4-r1 All selected packages: =dev-ruby/sass-3.5.7-r1 >>> 'Selected' packages are slated for removal. >>> 'Protected' and 'omitted' packages will not be removed. Would you like to unmerge these packages? [Yes/No] yes ..... .....