When I upgraded to Bionic, Ruby was upgraded from its default Xenial version 2.3 to its default Bionic version 2.5. That means that Ruby gem-provided programs that I installed via gem install no longer work, and gem uninstall doesn’t work either because it fails to find Ruby 2.3 and bails out.

I know it’s not good practice on Ubuntu to use gem to install Ruby libraries you need for development, and I haven’t, but I have used it to install executable programs that are distributed that way.

(My intention going forward is to use checkinstall and/or a PPA for such cases; I know better now. But this question is about the cleanup.)

To give an example, at this moment I have an unexecutable version of the Rubygem github-linguist, with its main runnable installed in /usr/local/bin/linguist. I can install the new Bionic apt package ruby-github-linguist, which besides installing into /usr/bin rather than /usr/local/bin, installs its executables under the names github-linguist and git-linguist, where the older Rubygem installed linguist and git-linguist (they are two different programs, with the new github-linguist corresponding to the old linguist).

So not only do I have a name clash (and for various reasons I put /usr/local/bin before /usr/bin in my PATH), but the old version in /usr/local/bin is impossible to execute, and gem uninstall fails as well.

As I said, I’ve learned my lesson, and hopefully by first making such programs (and similar cases like Python easy_install-based programs or Golang programs) into APTs in my PPA, I won’t have to deal with this when I upgrade from Bionic.

But right now, I already have this useless (at best) cruft on my system. How can I remove this and other pre-Bionic Ruby 2.3 gems from my system?

(I realize the answer is almost certainly different for executables installed using Python’s easy_install, Go’s go get, Haskell’s cabal install, Node’s npm -i, etc.—but if there is a single tool or strategy that can be used across such cases, so much the better.)


When you change ruby version, you should always run gem pristine --extensions to recompile C extensions. It may facilitate using your old gems under the new version of ruby. Have you tried that?

If you prefer to uninstall the old gems check Uninstall old versions of Ruby gems on Stack Overflow.

Otherwise, under Ubuntu there are two ways to manage multiple ruby versions and select the default one:

1) Use Ubuntu Snap rather than Apt - it'll allow you to choose which version to install, the latest or any prior one. See The official Ruby snap is available post on the Ruby.org website for instructions. To avoid possible conflicts, you may want to uninstall the existing apt installed version first by running

sudo apt remove ruby && sudo apt autoremove

Main advantage of installation with snap is the official support both by Ruby.org and Ubuntu. You can downgrade or upgrade the version to use. First run snap info ruby to list all the available versions (currently 2.3 through 2.7) and then follow the instructions linked above to select the versions to install (multiple versions can coexist) and to switch between them.

2) If you prefer to stick with Debian's Apt package management tool, you can rely on Brightbox PPA Ruby packages for Ubuntu which gives you almost the same choices (at present, they have yet to provide the very recent version 2.7). Here you'd have to rely on Brightbox to continue providing optimized Ruby packages for Ubuntu as they have done for years. They’re currently maintaining packages for Ruby 2.6, 2.5, 2.4, 2.3, 2.2, 2.1, 2.0, 1.9.3, and 1.8.7, and you can also switch the default Ruby version back and forth between the versions.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.