[QA] RVM and/or rbenv

Dan Duvall dduvall at wikimedia.org
Mon Jun 30 19:21:06 UTC 2014


TL;DR
I've decided to avoid both in server/automated environments and tend
towards rbenv + bundler for ruby/gem isolation in my local development
environments, though I don't think we need to endorse one or the other for
the latter. For mediawiki-vagrant, I actually reverted the use of rbenv via
Puppet in favor of distro packages which are new enough for browser tests
and much easier/faster to provision (there were already a few complaints
about how slow provisioning was after introducing rbenv).[1]

For those developing outside of mw-vagrant, I'm not sure there's any
empirical answer as to which is better, but there are a number of pros and
cons for different use cases. In my experience, it helps to consider how
each is implemented before deciding on whether to use it in a particular
environment.

First, some facts.

RVM implements:
 - installation of rubies (from source and binary packages)
 - isolation of rubies (into user- or system-wide sandboxes)
 - definition and isolation of "gemsets" (into sandboxes for each version
of ruby installed)
 - switching between versions of ruby *and gemsets* automatically by:
   - intercepting every invocation of `cd` using a bash alias[2] which
     - traverses directories upward for .ruby-version and .ruby-gemset files
     - prepends PATH (for ruby) and exports GEM_* env variables

rbenv implements:
 - installation of rubies* (from source only; *requires ruby-build plugin)
 - isolation of rubies (into user- or system-wide sandboxes)
 - switching between versions of ruby automatically by:
   - installing bin stubs for all ruby executables (ruby, gem, etc.) and
every installed gem
   - prepending PATH once per (sub-)shell
   - intercepting every invocation of a bin stub (ruby, gem, etc.; see
above) which
     - traverses directories upward for .ruby-version and
     - delegates to the corresponding version of the real binary

Second, my experience with each—and perhaps emotional response though let's
call it intuition.

RVM:
Both the out-of-the-box support for ruby installation—especially from
binary packages—and implementation of gemsets are useful when you hack on a
wide variety of disparate ruby projects. However, the hijacking of `cd`
seems like a huge hammer that I'm trepidatious about introducing anywhere
near a server, especially those that depend on automation through lots of
shell invocation—and, in fact, I never have used RVM in server environments
for this reason.

rbenv:
I appreciate the small footprint when compared to RVM, and installation of
rubies is easy enough (albeit slow) using ruby-build. The lack of gemsets
was annoying at first, but one can use `bundler --path` to achieve almost
the same thing, and since you're almost always invoking gem binaries via
`bundle exec`, real gemsets are actually overkill. The use of bin stubs
over hijacking `cd` seemed more sane at first, but it introduces
substantial lag when executing anything ruby related. Additionally, bin
stubs lead to shell-scripting fallacies where a binary seems to exist ([ -x
$bin] is true), but when executed returns "rbenv: command doesn't exist for
this ruby version." For these latter reasons, I am also hesitant to use
rbenv on servers.

Anyway, sorry for the long read. It really comes down to preference for
developers, and my preference is usually for tools that are less intrusive.
That's why I now use rbenv over RVM for local development.

1: https://gerrit.wikimedia.org/r/#/c/140877/
2:
http://stackoverflow.com/questions/5605277/how-does-rvm-detect-when-youve-changed-directories


On Sat, Jun 28, 2014 at 6:39 PM, Nikolas Everett <neverett at wikimedia.org>
wrote:

> For my part I don't know enough to have an opinion other than that we need
> something to do the dependency management and isolation. I don't care which
> one. I know puppet has an rbenv patch merged or waiting.
> On Jun 28, 2014 2:52 PM, "Chris McMahon" <christopher.mcmahon at gmail.com>
> wrote:
>
>>
>>
>>
>> On Sat, Jun 28, 2014 at 4:33 AM, Željko Filipin <zfilipin at wikimedia.org>
>> wrote:
>>
>>> This is mostly question for Dan Duvall, but I wanted to ask it in
>>> public, so others could contribute too.
>>>
>>> Dan, what are you thoughts about RVM[1] and rbenv[2]? Should we use one
>>> or the other exclusively? Or are there times when one or the other is the
>>> better choice?
>>>
>>> Are there other options?
>>>
>>> We are using RVM for browser tests, mostly because at the time we were
>>> starting the project I did not know about any other Ruby
>>> version/environment managers.
>>>
>>
>>  As I recall, it was also because I had recommendations from Ruby experts
>> at places like Groupon and Leandog who recommended RVM at the time.
>>
>>
>> _______________________________________________
>> QA mailing list
>> QA at lists.wikimedia.org
>> https://lists.wikimedia.org/mailman/listinfo/qa
>>
>>
> _______________________________________________
> QA mailing list
> QA at lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/qa
>
>


-- 
Dan Duvall
Automation Engineer
Wikimedia Foundation <http://wikimediafoundation.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wikimedia.org/pipermail/qa/attachments/20140630/5a7a943e/attachment-0001.html>


More information about the QA mailing list