The current .ruby-version detection stops one directory shy of the root directory. The loop breaks once it gets to / so /.ruby-version is never discovered. Supporting /.ruby-version just requires running the loop one more time after it reaches the root directory.
Currently $dir reaching the root directory ends the loop:
# Current
local dir="$PWD" version
until [[ -z "$dir" ]]; do
# detect .ruby-version
dir="${dir%/*}"
done
One solution is to set $dir before detecting the .ruby-version:
# Option A
local dir="$PWD/" version
until [[ -z "$dir" ]]; do
dir="${dir%/*}"
# detect .ruby-version
done
Another option is to switch to a while true loop and have a break condition before before $dir is set:
# Option B
local dir="$PWD" version
while true; do
# detect .ruby-version
[[ -z "$dir" ]] && break
dir="${dir%/*}"
done
I think we should support /.ruby-version both for the sake of consistency and so it can be used as a global default that works outside of the user's home directory.
The current .ruby-version detection stops one directory shy of the root directory. The loop breaks once it gets to
/
so/.ruby-version
is never discovered. Supporting/.ruby-version
just requires running the loop one more time after it reaches the root directory.Currently
$dir
reaching the root directory ends the loop:One solution is to set
$dir
before detecting the .ruby-version:Another option is to switch to a
while true
loop and have abreak
condition before before$dir
is set:I think we should support
/.ruby-version
both for the sake of consistency and so it can be used as a global default that works outside of the user's home directory.