From c215c623f4211c042bbf67f5e11977e16dbed653 Mon Sep 17 00:00:00 2001 From: Alex Eagle Date: Wed, 21 Feb 2024 13:37:47 -0800 Subject: [PATCH] chore: make it possible to override run_binary#use_default_shell_env (#762) Still not documented as public API. We think this leads to non-hermeticity and could cause cache misses, so it must be used with care. Part of https://github.com/aspect-build/rules_js/issues/1303 --- lib/private/run_binary.bzl | 3 ++- lib/tests/run_binary_expansions/BUILD.bazel | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/private/run_binary.bzl b/lib/private/run_binary.bzl index 7ba4210..ca3c32f 100644 --- a/lib/private/run_binary.bzl +++ b/lib/private/run_binary.bzl @@ -76,7 +76,7 @@ Possible fixes: mnemonic = ctx.attr.mnemonic if ctx.attr.mnemonic else None, progress_message = ctx.attr.progress_message if ctx.attr.progress_message else None, execution_requirements = ctx.attr.execution_requirements if ctx.attr.execution_requirements else None, - use_default_shell_env = False, + use_default_shell_env = ctx.attr.use_default_shell_env, env = dicts.add(ctx.configuration.default_shell_env, envs), input_manifests = tool_input_mfs, ) @@ -104,6 +104,7 @@ _run_binary = rule( "mnemonic": attr.string(), "progress_message": attr.string(), "execution_requirements": attr.string_dict(), + "use_default_shell_env": attr.bool(), }, **STAMP_ATTRS), ) diff --git a/lib/tests/run_binary_expansions/BUILD.bazel b/lib/tests/run_binary_expansions/BUILD.bazel index 73f094c..0b379bc 100644 --- a/lib/tests/run_binary_expansions/BUILD.bazel +++ b/lib/tests/run_binary_expansions/BUILD.bazel @@ -53,6 +53,9 @@ run_binary( }, progress_message = "doing some work to make %{output}", tool = ":expansions_sh", + # May introduce non-determinism; use with care! + # See e.g. https://github.com/bazelbuild/bazel/issues/4912 + use_default_shell_env = True, ) diff_test(