aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google
diff options
context:
space:
mode:
authorGravatar lberki <lberki@google.com>2018-04-18 11:44:14 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-04-18 11:45:23 -0700
commitd3d37f0c7da3eaf3277d0297cb93d81c161d8659 (patch)
tree5fcca45b8edbc20bbad59e5f9de474816b0e77a3 /src/main/java/com/google
parentc25b2d04869fc550ee866fada1586e03b1fe0329 (diff)
Keep LANG/LANGUAGE and related environment variables for the process spawned by "blaze run --direct_run".
RELNOTES: None. PiperOrigin-RevId: 193391379
Diffstat (limited to 'src/main/java/com/google')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java
index 8170ca2b14..14b05a721a 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/RunCommand.java
@@ -55,6 +55,7 @@ import com.google.devtools.build.lib.packages.TargetUtils;
import com.google.devtools.build.lib.pkgcache.LoadingFailedException;
import com.google.devtools.build.lib.runtime.BlazeCommand;
import com.google.devtools.build.lib.runtime.BlazeCommandResult;
+import com.google.devtools.build.lib.runtime.BlazeServerStartupOptions;
import com.google.devtools.build.lib.runtime.Command;
import com.google.devtools.build.lib.runtime.CommandEnvironment;
import com.google.devtools.build.lib.runtime.ProcessWrapperUtil;
@@ -532,6 +533,20 @@ public class RunCommand implements BlazeCommand {
}
}
+ // We need to do update runEnvironment so that the environment of --batch is not contaminated
+ // with that required for the server. Note that some differences between the environment of
+ // the process being run and the environment of the client are still possible if the environment
+ // variables added for the server were not in the original client environment.
+ //
+ // This is done after writing the script for --script_path so that that is not contaminated
+ // with the original client environment (CommandFailureUtils.describeCommand() puts
+ // runEnvironment into the written script)
+ boolean batchMode = env.getRuntime().getStartupOptionsProvider()
+ .getOptions(BlazeServerStartupOptions.class).batch;
+ if (batchMode) {
+ runEnvironment.putAll(env.getClientEnv());
+ }
+
env.getReporter().handle(Event.info(
null, "Running command line: " + ShellEscaper.escapeJoinAll(cmdLine)));