in bazel/bazel.go [99:128]
func findBazel() string {
// Trust the user, if they supplied a path we always use it
if len(*bazelPathFlag) > 0 {
return *bazelPathFlag
}
// Frontend devs may have installed @bazel/bazelisk and @bazel/ibazel from npm
// If they also have bazelisk in the $PATH, we want to resolve this one, to avoid version skew
if npmPath, err := bazeliskNpmPath(filepath.ToSlash(os.Args[0])); err == nil {
return filepath.FromSlash(npmPath)
}
// Frontend devs may have installed @bazel/bazel and @bazel/ibazel from npm
// If they also have bazel in the $PATH, we want to resolve this one, to avoid version skew
if npmPath, err := bazelNpmPath(filepath.ToSlash(os.Args[0])); err == nil {
return filepath.FromSlash(npmPath)
}
// Check in $PATH for system-installed Bazelisk
if path, err := exec.LookPath("bazelisk"); err == nil {
return path
}
// Check in $PATH for system-installed Bazel
if path, err := exec.LookPath("bazel"); err == nil {
return path
}
// If we've fallen through to here, the lookup won't succeed.
// Return "bazel" so that we'll later fail with an error
// exec: "bazel": executable file not found in $PATH
// which helps the user understand that we looked in the $PATH
return "bazel"
}