RVM and rbenv seem like hacky solutions to a problem that is easily solved by specifying dependency versions in your project.
RVM and rbenv seem like hacky solutions to a problem that is easily solved by specifying dependency versions in your project.
The same problem also occurs with libraries, which may also have their own executables, so these tools have tried to solve both problems - which is slightly more complicated than a three line shell script. Bundler has become the standard way of managing libraries, so now something like chruby[0] can be used to do pretty much what you said for the interpreter alone. Of course the other tools (that do a lot more) still have their historical followers...
If you are wondering why you need to support multiple versions, these tools are mainly for use in development environments where you will probably have to support legacy software that is no longer actively maintained.
[0] https://github.com/postmodern/chruby/blob/master/share/chrub...
As others mention, scripts typically just run "ruby" (via shebang or directly), which will pick whatever is the default.
Debian/Ubuntu have the "alternatives" system, which is designed to solve this for any kind of program, but it's virtually impossible to use by humans; there's no single command to switch between versions.
Fortunately, the ruby-switch package [1] wraps the terrible UI in a single command to switch versions. I highly recommend it.
Of course, this switches the version globally. To get per-shell Ruby versions, you will need the other tools mentioned in this thread.
Even if you're running an operation small enough that you can upgrade every single runtime in use all in one step, you'll still need to have two versions around while you test. But many, many places have to deal with multiple language versions simultaneously. E.g., if you maintain an open source library and have any regard for your users, you have to test how it behaves in multiple language versions.
(java is not fully backwards compatible either, but it may be a bit more tolerant in some cases)
As for how fun upgrading to rails4 is, you obviously don't have a project with 200 database tables that has models using the attr_protected for the five columns (appwide) that actually need it. Forced whitelisting is not fun, regardless of if it is on model or controller level.
> It should be simple to have multiple versions of libraries
> coexisting on a system.
This is a language issue, not a tooling issue.Why should I have to install a single library in multiple places in my system, if I have multiple versions of Ruby installed? It's a disaster for upgrades and deployment.
Plus, tools like RVM and rbenv seem to depend on a bunch of hacky symlinking and $PATH manipulation to make things work. Ensuring that developers' laptops have the same environment as production boxes is not trivial, no matter what the authors of these tools claim.