Fix misleading error message (#927)
When `rctx.which` can not find a program for the specified name, it
returns `None`.
We should not override the original `python_interpreter` in this case,
otherwise we'll see a misleading error message like `Error in fail:
python interpreter `None` not found in PATH`
diff --git a/python/pip_install/pip_repository.bzl b/python/pip_install/pip_repository.bzl
index f5a2da2..782a947 100644
--- a/python/pip_install/pip_repository.bzl
+++ b/python/pip_install/pip_repository.bzl
@@ -60,11 +60,11 @@
if rctx.attr.python_interpreter_target != None:
target = rctx.attr.python_interpreter_target
python_interpreter = rctx.path(target)
- else:
- if "/" not in python_interpreter:
- python_interpreter = rctx.which(python_interpreter)
- if not python_interpreter:
+ elif "/" not in python_interpreter:
+ found_python_interpreter = rctx.which(python_interpreter)
+ if not found_python_interpreter:
fail("python interpreter `{}` not found in PATH".format(python_interpreter))
+ python_interpreter = found_python_interpreter
return python_interpreter
def _get_xcode_location_cflags(rctx):