I'm trying to get some Ruby project running and the project is using .ruby-version
file. That file contains only:
1.9.3
I installed the latest Ruby 1.9.3:
$ rbenv install 1.9.3-p448
However when I ran ruby --version
I got
rbenv: version '1.9.3' is not installed
To fix this error I listed ~/.rbenv/versions/
and it contained the folder 1.9.3-p448
. I renamed that folder to 1.9.3
and ran rbenv rehash
. This fixed the problem.
Looks like the -p448
part (What does it mean? Patch?) confuses rbenv. How can I make it recognise the correct 1.9.3 version without manually renaming the folder in ~/.rbenv
? I could also change .ruby-version
to 1.9.3-p448
, but that means that the project will depend on my particular "patch" of Ruby 1.9.3, which is bad.
rbenv doesn't allow this. From the wiki:
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.
mislav's comment from A Common .ruby-version File For Ruby Projects:
rbenv is going to support
.ruby-version
, but definitely without any fuzzy matching. Here's why I think fuzzy matching is a bad idea:
- Let's suppose I have 1.9.3-p0 installed.
- I put "ruby-1.9" to
.ruby-version
in my project and all is well.- After some time I install 1.9.3-p300 to try it out and suddenly all my projects marked with "ruby-1.9" automatically upgrade to it. Gems need to be reinstalled, native extensions need to be upgraded, etc. Nightmare.
One of the important reasons why we have version managers is to be precise about versions. rbenv is going to be precise. If you want cute shortcuts & aliases, you can always make symlinks.
.ruby-version
file by setting the RBENV_VERSION
environment variable (e.g. for the current shell by running rbenv shell 1.9.3-p448
).1.9.3
to 1.9.3-p448
, see rbenv-aliases for details.