Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 4 commits into from

Conversation

tmatilai
Copy link
Contributor

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.

@tmatilai
Copy link
Contributor Author

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

@postmodern
Copy link
Owner

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.

@tmatilai
Copy link
Contributor Author

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

@postmodern
Copy link
Owner

Going to try to include this behaviour in 0.3.3.

@tmatilai
Copy link
Contributor Author

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.

@tmatilai
Copy link
Contributor Author

@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.

@postmodern
Copy link
Owner

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

Extract probing of one directory level to own function, so we can later
use it to set default ruby from ~/.ruby-version.
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.
@postmodern
Copy link
Owner

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

@hovsater
Copy link
Contributor

hovsater 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?

@davidcelis
Copy link

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

@caleb
Copy link

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?

@havenwood
Copy link
Collaborator

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

@caleb
Copy link

caleb commented Nov 13, 2014

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

@postmodern postmodern added this to the 0.4.0 milestone Nov 17, 2014
@havenwood
Copy link
Collaborator

Support for a .ruby-version file in / was added in 2e991e4.

@tmatilai tmatilai closed this Jan 8, 2019
@tmatilai tmatilai deleted the default-ruby-version branch January 8, 2019 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants