public static String determineGlobalInstallation()

in rake-runner-agent/src/jetbrains/buildServer/agent/ruby/rbenv/detector/RbEnvDetectorForUNIX.java [67:107]


  public static String determineGlobalInstallation(@NotNull final Map<String, String> env) {
    // Try to detect global rbenv on dist
    // Known paths: /usr/local/rbenv
    for (String knowHomePath : KNOW_GLOBAL_RBENV_HOME_PATHS) {
      final String exec = knowHomePath + "/bin/rbenv";

      try {
        if (FileUtil2.checkIfExists(exec)) {
          // rbenv installation detected!
          // Checking we have permissions
          if (InstalledRbEnv.executeCommandLine(exec, "help").contains("usage: rbenv")) {
            return knowHomePath;
          }
        }
      } catch (Exception ignored) {
      }
      // continue search..
    }
    // HomeBrew ( /usr/local/Cellar/rbenv/x.x.x/ as home and /usr/local/bin/rbenv as binary )
    try {
      for (String val : new String[]{OSUtil.findExecutableByNameInPATH("rbenv", env), USR_LOCAL_BIN_RBENV}) {
        if (val == null) continue;
        final File home = getResolvedHome(val);
        if (home == null) continue;
        if (home.isDirectory() && home.exists()) {
          final File exec = new File(home, "bin/rbenv");
          if (exec.exists()) {
            // rbenv installation detected!
            // Checking we have permissions
            if (InstalledRbEnv.executeCommandLine(exec.getAbsolutePath(), "help").contains("sage: rbenv")) {
              return home.getAbsolutePath();
            }
          }
        }
      }
    } catch (Throwable ignored) {
    }

    // No global rbenv was found
    return null;
  }