Skip to content

Commit 627830e

Browse files
authored
fix(internal): correctly template error message in repository rules (bazel-contrib#1779)
Fixes "Error in format: Missing argument 'path'" error and correctly templates the binary name and `PATH`. ``` (17:54:57) ERROR: /Users/jesses/work/canva/WORKSPACE:120:17: fetching whl_library rule //external:pypi_jsmin: Traceback (most recent call last): File "/private/var/tmp/_bazel_jesses/06c990151bb0d0bcaaf7ea85520191a3/external/rules_python/python/pip_install/pip_repository.bzl", line 783, column 59, in _whl_library_impl environment = _create_repository_execution_environment(rctx, python_interpreter) File "/private/var/tmp/_bazel_jesses/06c990151bb0d0bcaaf7ea85520191a3/external/rules_python/python/pip_install/pip_repository.bzl", line 257, column 47, in _create_repository_execution_environment cppflags.extend(_get_xcode_location_cflags(rctx)) File "/private/var/tmp/_bazel_jesses/06c990151bb0d0bcaaf7ea85520191a3/external/rules_python/python/pip_install/pip_repository.bzl", line 121, column 46, in _get_xcode_location_cflags arguments = [repo_utils.which_checked(rctx, "xcode-select"), "--print-path"], File "/private/var/tmp/_bazel_jesses/06c990151bb0d0bcaaf7ea85520191a3/external/rules_python/python/private/repo_utils.bzl", line 164, column 39, in _which_checked " PATH = {path}".format(rctx.os.environ.get("PATH")))) Error in format: Missing argument 'path' ```
1 parent 9a1a524 commit 627830e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

python/private/repo_utils.bzl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,13 @@ def _which_checked(rctx, binary_name):
160160
"""
161161
binary = rctx.which(binary_name)
162162
if binary == None:
163-
fail(("Unable to find the binary '{binary_name}' on PATH.\n" +
164-
" PATH = {path}".format(rctx.os.environ.get("PATH"))))
163+
fail((
164+
"Unable to find the binary '{binary_name}' on PATH.\n" +
165+
" PATH = {path}"
166+
).format(
167+
binary_name = binary_name,
168+
path = rctx.os.environ.get("PATH"),
169+
))
165170
return binary
166171

167172
def _args_to_str(arguments):

0 commit comments

Comments
 (0)