~/.ruby-version sets default ruby only for home directory tree #85

Open
wants to merge 4 commits into
from

Conversation

Projects
None yet
6 participants
Contributor

tmatilai commented Mar 14, 2013

The "Default Ruby" section in the Readme indicates that ~/.ruby-version would set the default ruby the same way as calling chruby. Actually it only sets it for the home directory and its subdirectories.

I'm not sure if this is a problem for anyone, but maybe the wording in the readme should be tweaked a bit? If a true default value is wanted then chruby_auto should try to find and use ~/.ruby-version as a fallback before resetting to system ruby.

Contributor

tmatilai commented Jan 27, 2013

Oh, and thank you very much for the great project! chruby seems to make all that you need and nothing extra for ruby version management. The biggest problem so far is that I keep typing chroot instead of chruby. :D

Owner

postmodern commented Jan 27, 2013

Ah good point. This was some-what intentional to reuse the sub-directory behaviour for the "default" Ruby. We can change it use ~/.ruby-version as the fall-back file, if no other .ruby-version could be found.

Contributor

tmatilai commented Jan 27, 2013

OK, I can take a look later.
I guess the tests require more work than the implementation. As always. =)

Owner

postmodern commented Feb 9, 2013

Going to try to include this behaviour in 0.3.3.

Contributor

tmatilai commented Feb 9, 2013

I already started to hack something up a while ago. I pushed it now to my default-ruby-version branch. Feel free to comment, use, cherry-pick, ignore, etc. I can also change this issue to pull request based on that branch if you want.

Tests are now quite dependent on the system configuration. I'll open another issue with my findings.

Contributor

tmatilai commented Mar 13, 2013

@postmodern do you have any comments on this?

I'm actually not using the auto-switcher myself at the moment so this is not an issue for me personally.

Owner

postmodern commented Mar 13, 2013

I need to get around to merge your code this weekend.

tmatilai added some commits Feb 9, 2013

@tmatilai tmatilai Refactor auto-switching iteration
Extract probing of one directory level to own function, so we can later
use it to set default ruby from ~/.ruby-version.
3be2316
@tmatilai tmatilai Default to ~/.ruby-version also outside home directory fa4b9f6
@tmatilai tmatilai Fix assert message 72b2fb5
@tmatilai tmatilai Only try auto-switch using a particular .ruby-version once
Set RUBY_VERSION_FILE also if .ruby-version is invalid, so that we don't
try to use it again and again. Otherwise error messages are printed
after each command.

The downside is that the .ruby-version won't be automatically read after
fixed. But we do not read modified valid .ruby-files, either.
fc6e4ed
Owner

postmodern commented Apr 12, 2013

I like this idea. I'm considering rewriting chruby-exec as a function, that way it could make use of chruby_auto.

Contributor

KevinSjoberg commented Sep 2, 2013

I like this idea. I just got bitten by this exact issue and was thinking of making a pull request until I noticed this issue. I think it's fair to assume that it fallback to ~/.ruby-version if traversing the parent directories yield no result.

Any update on this yet?

This would be great. I'd hate to have to put a .ruby-version file in the root directory.

caleb commented Nov 12, 2014

I would love this patch or something like it to make it in. I often forget to chruby when I navigate to a different drive or folder on my machine.

Is there anything I can do to make this patch or one like it make it into chruby?

Collaborator

havenwood commented Nov 13, 2014

Here's a stab at supporting ~/.ruby-version without changing the function structure, just to see what that might look like: havenwood/chruby@47c6b6c

caleb commented Nov 13, 2014

@havenwood That patch works well on my system with ZSH.

postmodern added this to the 0.4.0 milestone Nov 17, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment