Flip `--incompatible_merge_fixed_and_default_shell_env`
Fixes #5980
Closes #19317
RELNOTES[INC]: --incompatible_merge_fixed_and_default_shell_env is flipped to true. See #19317 for details.
Closes #19318.
PiperOrigin-RevId: 560669897
Change-Id: I7c7e3267e55deca3b889796293930a33b77b2d91
diff --git a/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java b/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java
index f741b03..a17c9d1 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java
@@ -670,7 +670,7 @@
@Option(
name = "incompatible_merge_fixed_and_default_shell_env",
- defaultValue = "false",
+ defaultValue = "true",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS},
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
@@ -871,7 +871,7 @@
public static final String INCOMPATIBLE_DISABLE_STARLARK_HOST_TRANSITIONS =
"-incompatible_disable_starlark_host_transitions";
public static final String INCOMPATIBLE_MERGE_FIXED_AND_DEFAULT_SHELL_ENV =
- "-experimental_merge_fixed_and_default_shell_env";
+ "+experimental_merge_fixed_and_default_shell_env";
public static final String INCOMPATIBLE_OBJC_PROVIDER_REMOVE_LINKING_INFO =
"-incompatible_objc_provider_remove_linking_info";
diff --git a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkActionFactoryApi.java b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkActionFactoryApi.java
index b380a71..08d78cb 100644
--- a/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkActionFactoryApi.java
+++ b/src/main/java/com/google/devtools/build/lib/starlarkbuildapi/StarlarkActionFactoryApi.java
@@ -417,7 +417,16 @@
defaultValue = "False",
named = true,
positional = false,
- doc = "Whether the action should use the built in shell environment or not."),
+ doc =
+ "Whether the action should use the default shell environment, which consists of a"
+ + " few OS-dependent variables as well as variables set via <a"
+ + " href=\"/reference/command-line-reference#flag--action_env\"><code>"
+ + "--action_env</code></a>.<p>If both <code>use_default_shell_env</code> and"
+ + " <code>env</code> are set to <code>True</code>, values set in"
+ + " <code>env</code> will overwrite the default shell environment if <a "
+ + "href=\"/reference/command-line-reference#flag--incompatible_merge_fixed_and_default_shell_env\"><code>--incompatible_merge_fixed_and_default_shell_env</code></a>"
+ + " is enabled (default). If the flag is not enabled, <code>env</code> is"
+ + " ignored."),
@Param(
name = "env",
allowedTypes = {
@@ -427,7 +436,14 @@
defaultValue = "None",
named = true,
positional = false,
- doc = "Sets the dictionary of environment variables."),
+ doc =
+ "Sets the dictionary of environment variables.<p>If both"
+ + " <code>use_default_shell_env</code> and <code>env</code> are set to"
+ + " <code>True</code>, values set in <code>env</code> will overwrite the"
+ + " default shell environment if <a "
+ + "href=\"/reference/command-line-reference#flag--incompatible_merge_fixed_and_default_shell_env\"><code>--incompatible_merge_fixed_and_default_shell_env</code></a>"
+ + " is enabled (default). If the flag is not enabled, <code>env</code> is"
+ + " ignored."),
@Param(
name = "execution_requirements",
allowedTypes = {
@@ -664,7 +680,16 @@
defaultValue = "False",
named = true,
positional = false,
- doc = "Whether the action should use the built in shell environment or not."),
+ doc =
+ "Whether the action should use the default shell environment, which consists of a"
+ + " few OS-dependent variables as well as variables set via <a"
+ + " href=\"/reference/command-line-reference#flag--action_env\"><code>"
+ + "--action_env</code></a>.<p>If both <code>use_default_shell_env</code> and"
+ + " <code>env</code> are set to <code>True</code>, values set in"
+ + " <code>env</code> will overwrite the default shell environment if <a "
+ + "href=\"/reference/command-line-reference#flag--incompatible_merge_fixed_and_default_shell_env\"><code>--incompatible_merge_fixed_and_default_shell_env</code></a>"
+ + " is enabled (default). If the flag is not enabled, <code>env</code> is"
+ + " ignored."),
@Param(
name = "env",
allowedTypes = {
@@ -674,7 +699,14 @@
defaultValue = "None",
named = true,
positional = false,
- doc = "Sets the dictionary of environment variables."),
+ doc =
+ "Sets the dictionary of environment variables.<p>If both"
+ + " <code>use_default_shell_env</code> and <code>env</code> are set to"
+ + " <code>True</code>, values set in <code>env</code> will overwrite the"
+ + " default shell environment if <a "
+ + "href=\"/reference/command-line-reference#flag--incompatible_merge_fixed_and_default_shell_env\"><code>--incompatible_merge_fixed_and_default_shell_env</code></a>"
+ + " is enabled (default). If the flag is not enabled, <code>env</code> is"
+ + " ignored."),
@Param(
name = "execution_requirements",
allowedTypes = {
diff --git a/src/test/java/com/google/devtools/build/lib/packages/semantics/ConsistencyTest.java b/src/test/java/com/google/devtools/build/lib/packages/semantics/ConsistencyTest.java
index fcf26cf..d92a505 100644
--- a/src/test/java/com/google/devtools/build/lib/packages/semantics/ConsistencyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/packages/semantics/ConsistencyTest.java
@@ -142,6 +142,7 @@
"--incompatible_disallow_struct_provider_syntax=" + rand.nextBoolean(),
"--incompatible_do_not_split_linking_cmdline=" + rand.nextBoolean(),
"--incompatible_java_common_parameters=" + rand.nextBoolean(),
+ "--incompatible_merge_fixed_and_default_shell_env=" + rand.nextBoolean(),
"--incompatible_new_actions_api=" + rand.nextBoolean(),
"--incompatible_no_attr_license=" + rand.nextBoolean(),
"--incompatible_no_implicit_file_export=" + rand.nextBoolean(),
@@ -190,6 +191,8 @@
BuildLanguageOptions.INCOMPATIBLE_DISALLOW_STRUCT_PROVIDER_SYNTAX, rand.nextBoolean())
.setBool(BuildLanguageOptions.INCOMPATIBLE_DO_NOT_SPLIT_LINKING_CMDLINE, rand.nextBoolean())
.setBool(BuildLanguageOptions.INCOMPATIBLE_JAVA_COMMON_PARAMETERS, rand.nextBoolean())
+ .setBool(
+ BuildLanguageOptions.INCOMPATIBLE_MERGE_FIXED_AND_DEFAULT_SHELL_ENV, rand.nextBoolean())
.setBool(BuildLanguageOptions.INCOMPATIBLE_NEW_ACTIONS_API, rand.nextBoolean())
.setBool(BuildLanguageOptions.INCOMPATIBLE_NO_ATTR_LICENSE, rand.nextBoolean())
.setBool(BuildLanguageOptions.INCOMPATIBLE_NO_IMPLICIT_FILE_EXPORT, rand.nextBoolean())
diff --git a/src/test/shell/integration/action_env_test.sh b/src/test/shell/integration/action_env_test.sh
index 1dd4269..ef87479 100755
--- a/src/test/shell/integration/action_env_test.sh
+++ b/src/test/shell/integration/action_env_test.sh
@@ -253,7 +253,6 @@
ACTION_AND_CLIENT_INHERITED=client CLIENT_INHERITED=client \
bazel build \
- --incompatible_merge_fixed_and_default_shell_env \
--action_env=ACTION_AND_CLIENT_FIXED=client \
--action_env=ACTION_AND_CLIENT_INHERITED \
--action_env=CLIENT_FIXED=client \