in rake-runner-agent/src/jetbrains/buildServer/agent/ruby/rbenv/detector/RbEnvDetectorForUNIX.java [25:52]
public InstalledRbEnv detect(@NotNull final Map<String, String> env) {
// 1. Read "RBENV_ROOT" env variable
// 2. Try to find local rbenv (RBENV_ROOT = $HOME/.rbenv)
// 3. Try to find global rbenv (RBENV_ROOT = /usr/local/.rbenv)
// NOTE: Steps 2 and 3 via 'which rbenv'
// custom or system wide rbenv path
@Nullable final String special = determinePathUsingEnvVariable(env);
@Nullable final String global = determineGlobalInstallation(env);
@Nullable final String local = determineLocalInstallation();
if (special != null) {
if (local != null && special.equals(local)) {
return new InstalledRbEnv(local, InstalledRbEnv.Type.Local);
} else if (global != null && special.equals(global)) {
return new InstalledRbEnv(global, InstalledRbEnv.Type.Global);
} else {
return new InstalledRbEnv(special, InstalledRbEnv.Type.Special);
}
} else if (local != null) {
return new InstalledRbEnv(local, InstalledRbEnv.Type.Local);
} else if (global != null) {
return new InstalledRbEnv(global, InstalledRbEnv.Type.Global);
} else {
// Nothing founded
return null;
}
}