This is a little thought on packaged Ruby versions (mostly in Linux-based systems) and why I don’t get many people advising newcomers to start by installing RVM when in reality they just want to program Ruby.
If you are a beginner or someone who just want to try Ruby chances are you don’t need a Ruby version manager. This is especially true on systems such as Fedora that always have a new Ruby version available (time to switch to Fedora!), but also kind of true on others (even latest Mac OS X/macOS has at least 2.0 and when I used Mac OS it was even pre-installed!).
What I don’t find ideal is that so many Ruby tutorials are just starting with installing a Ruby version manager (often RVM). I have seen beginners to install RVM for a one-day-i-want-to-try-it-out. “But RVM is great!” you say? Perhaps, but every tool introduce some complexity. Why do you want to use a version manager – learn it and fight it when you don’t yet understand it – even before actually programming Ruby for a while?
What is even worse is that our community actively discourage the use of packaged (system) Ruby. Yes it’s packaged for programs that actually need it as a dependency, but it’s also there for everybody else! Big companies pay big money to be able to use tested and security-patched packages (be it Ruby or Apache HTTP server) on enterprise platforms and you don’t even take 5 minutes to find out if it can suit your need?
But I not only like to use system Ruby for development, I also use it for deployment when I can. Getting security patches for free with system updates is nice. Managing as many components with system package managers (such as DNF) is great and that’s why we have them. Yet so many people out there oppose the idea it seems. “Lock the application dependencies” they say!
For me the choice is about security (updates for free) and reduced complexity (not managing another tool in production especially not a tool that suggest its installation by running a remote bash script!).
So is there any disadvantage to this? Of course! If there isn’t people would not invent version managers in the first place! For one you might be getting really old version with your system, sometimes that old that upstream don’t support it any longer (but the vendor might!). To battle this problem Red Hat offered newer versions as Software Collections, but true, then you have to go learn about scl-utils instead of RVM, which is not that ideal either.
The other disadvantage might be not getting some features that more complex version managers offer, such as gem sets. In my opinion Bundler does a good job at putting the $LOAD_PATH
together so there isn’t anything I would really miss, but I am not saying you might.
Even though many people teach people Ruby by telling them about RVM, the official Ruby web actually advocates the right thing to do which makes me quite happy!
And so how do I manage my Ruby versions you ask? If the Ruby in my Fedora does not meet the requirement I use ruby-install to install new versions and chruby to change them. I am not advocating that they are the best, but there are very simple and that’s what I like about them the most.
I might also just change the Gemfile
to be able to use my version of Ruby like this:
ruby_version_file = File.expand_path('../.ruby-version', __FILE__)
version = File.read(ruby_version_file).gsub(/ruby-(.*)/, '\1') if File.exists?(ruby_version_file)
ruby ENV['PROJECT_RUBY_VERSION'] || version
On production systems I always use packaged Ruby in my own projects.
In my mind I treat Ruby the same as Python, Perl or Node.js on my system. They come nicely packaged, tested and with security updates. Why should I be fighting something that actually works for me? Why should I install various version managers for various runtimes and learn how to use each one of them? In my opinion this does not scale well :).
Edit: I knew it’s a bit controversial topic for some, but that’s why I wrote it! Read the Reddit comments about this article and my responses.
I will respond to one thing though directly here. The idea that using system rubies is so difficult for begginers:
Please spend some time looking through this subreddit and take note of how many help requests there are from people whom have issues using the system installed Ruby. It’s not disinformation, it’s experience.
Here is my experience, taken from Ask HN: Why did you stop learning to code? that I have seen today:
…I’ve tried to learn Rails for example, following Michael Hartls’ step by step tutorial, and even then I get stuck. Suddenly I’m lost with homebrew, updating my PATH, rvm, gemsets, versions, etc. To build a simple website, I have to learn about nodejs, bower, grunt, API’s, databases…
So here you have it. Removing version managers and compilation steps helps beginners. Google “rvm not found” to get the idea how many people struggle with this.
Author is a Fedora contributor and a formal Red Hat employee.