Rbenv: option to ignore .ruby-version file?

Created on 27 Jan 2013  路  4Comments  路  Source: rbenv/rbenv

we are using rbenv in our continuous integration environment

I noticed the following in the documentation (which seems reasonable to me)

Other version managers might allow fuzzy version matching on the string read from .ruby-version file, e.g. they might allow "1.9.3" (without patch suffix) to match the latest Ruby 1.9.3 release. rbenv will not support this, because such behavior is unpredictable and therefore harmful.

The problem is that people are checking in very specific ruby versions into their repositories. If we don't have these exact ruby versions installed on our CI servers they get an error

rbenv: version `1.9.3-p362' is not installed

I was wondering if you had any suggestions for workarounds (other than installing every single Ruby version). Thanks!

Most helpful comment

I just did this:

rbenv shell $(rbenv global)

Nice and easy to remember way to quickly override .ruby-version.

All 4 comments

You can globally export RBENV_VERSION=... in your CI environment to configure it to always use a single Ruby version that is installed.

I don't recommend this, however. Your CI should use the same Ruby version for a project that you're developing on and deploying with.

Problem is that rbenv doesn't have a build for the specific version of Ruby we require in production. We have mixed RVM/RBENV usage in house and RVM has a build for the specified version. What do you recommend in that situation?

rbenv doesn't have _any_ builds. It's the ruby-build project that knows how to build Ruby and has specific naming conventions for that. All that rbenv cares about is that there's a named directory in $RBENV_ROOT/versions/.

If you run a specific verson of Ruby in production, then your developers should be able to build the same version on their systems and symlink that into ~/.rbenv/versions/X.Y.Z. If you name that directory the same as the string that appears in your .ruby-version file (which you said works with RVM), it will work with rbenv as well.

Bottom line is: you're not limited.

I just did this:

rbenv shell $(rbenv global)

Nice and easy to remember way to quickly override .ruby-version.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dazza-codes picture dazza-codes  路  4Comments

alankis picture alankis  路  5Comments

slayer picture slayer  路  4Comments

ghost picture ghost  路  4Comments

ghost picture ghost  路  5Comments