Closed DavidEGrayson closed 9 years ago
It's already noted in the README that auto.sh
and chruby.sh
are separate for those that do not want/need auto-switching.
If you're already requiring chruby and need auto-switching, then simply require that the user enables it? OTOH, chruby's auto-switching is designed to be unobtrusive and just work everywhere; provided it's loaded into the shell. Instead of explicitly calling chruby_auto
, why not just use a .ruby-version
file and allow the user's preferred Ruby Switcher to detect it?
I didn't want true auto-switching to be enabled because it would automatically make changes to the environment and it would likely be incompatible with other Ruby switchers. Still, I wanted to be able to run a command that is equivalent to "rvm rvmrc load" in my scripts when I need it.
I second David's suggestion. There are lots of times you wouldn't want to load auto.sh
but still want to do a one-time load of an environment specified by .ruby-version
. For example, on a production server, having that trap running after every Bash command might be too much of a risk.
Today I changed a project from using RVM to using chruby. I had to replace the following line in a shell script:
with this line:
The unpleasant thing about this is that I had to hardcode the path to the
.ruby-version
file, so the shell script will be more likely to break in the future, and if it gets copied to a different directory then that line would have to be modified.Really what I would like to do is call some chruby function that searches up the directory tree for a
.ruby-version
file and then uses it. That's what thechruby_auto
function does. I would suggest that thechruby_auto
function should be moved fromauto.sh
tochruby.sh
so it can be called without forcing the user to enable the auto-switching feature.It would be even better if there were a function available in
chruby.sh
that was likechruby_auto
but also emitted an error if it fails to find the.ruby-version
file and switch rubies.