-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
/
Copy pathactions_path.patch
41 lines (40 loc) · 2.26 KB
/
actions_path.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
diff --git a/src/main/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProvider.java b/src/main/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProvider.java
index 6fff2af..7e2877e 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/local/PosixLocalEnvProvider.java
@@ -47,6 +47,16 @@ public final class PosixLocalEnvProvider implements LocalEnvProvider {
Map<String, String> env, BinTools binTools, String fallbackTmpDir) {
ImmutableMap.Builder<String, String> result = ImmutableMap.builder();
result.putAll(Maps.filterKeys(env, k -> !k.equals("TMPDIR")));
+
+ // In case we are running on NixOS.
+ // If bash is called with an unset PATH on this platform,
+ // it will set it to /no-such-path and default tools will be missings.
+ // See, https://github.com/NixOS/nixpkgs/issues/94222
+ // So we ensure that minimal dependencies are present.
+ if (!env.containsKey("PATH")){
+ result.put("PATH", "@actionsPathPatch@");
+ }
+
String p = clientEnv.get("TMPDIR");
if (Strings.isNullOrEmpty(p)) {
// Do not use `fallbackTmpDir`, use `/tmp` instead. This way if the user didn't export TMPDIR
index 95642767c6..39d3c62461 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/local/XcodeLocalEnvProvider.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/local/XcodeLocalEnvProvider.java
@@ -74,6 +74,16 @@ public final class XcodeLocalEnvProvider implements LocalEnvProvider {
ImmutableMap.Builder<String, String> newEnvBuilder = ImmutableMap.builder();
newEnvBuilder.putAll(Maps.filterKeys(env, k -> !k.equals("TMPDIR")));
+
+ // In case we are running on NixOS.
+ // If bash is called with an unset PATH on this platform,
+ // it will set it to /no-such-path and default tools will be missings.
+ // See, https://github.com/NixOS/nixpkgs/issues/94222
+ // So we ensure that minimal dependencies are present.
+ if (!env.containsKey("PATH")){
+ newEnvBuilder.put("PATH", "@actionsPathPatch@");
+ }
+
String p = clientEnv.get("TMPDIR");
if (Strings.isNullOrEmpty(p)) {
// Do not use `fallbackTmpDir`, use `/tmp` instead. This way if the user didn't export TMPDIR