mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
5c1094adb9
finding_local_version_file is extremely slow, when working directory is under the UNC path. Because //host/.rbenv-version and //.rbenv-version do not exist, but testing them is so slow. It's the reason to make a serious delay of the response, when the Ruby runs with a current working directory under the UNC path under Cygwin environment. A response of before applying this patch. //somehost/somedir $ time ruby -e "exit" real 0m13.922s user 0m0.168s sys 0m0.287s A response of after applying this patch. //somehost/somedir $ time ruby -e "exit" real 0m0.721s user 0m0.153s sys 0m0.319s
33 lines
841 B
Bash
Executable file
33 lines
841 B
Bash
Executable file
#!/usr/bin/env bash
|
|
# Summary: Detect the file that sets the current rbenv version
|
|
set -e
|
|
[ -n "$RBENV_DEBUG" ] && set -x
|
|
|
|
find_local_version_file() {
|
|
local root="$1"
|
|
while [[ -n "$root" && ! "$root" =~ ^//[^/]*$ ]]; do
|
|
if [ -e "${root}/.ruby-version" ]; then
|
|
echo "${root}/.ruby-version"
|
|
exit
|
|
elif [ -e "${root}/.rbenv-version" ]; then
|
|
echo "${root}/.rbenv-version"
|
|
exit
|
|
fi
|
|
root="${root%/*}"
|
|
done
|
|
}
|
|
|
|
find_local_version_file "$RBENV_DIR"
|
|
[ "$RBENV_DIR" = "$PWD" ] || find_local_version_file "$PWD"
|
|
|
|
global_version_file="${RBENV_ROOT}/version"
|
|
|
|
if [ -e "$global_version_file" ]; then
|
|
echo "$global_version_file"
|
|
elif [ -e "${RBENV_ROOT}/global" ]; then
|
|
echo "${RBENV_ROOT}/global"
|
|
elif [ -e "${RBENV_ROOT}/default" ]; then
|
|
echo "${RBENV_ROOT}/default"
|
|
else
|
|
echo "$global_version_file"
|
|
fi
|