Commit 60bc017
Add
This PR introduces a new flag `--experimental_strict_repo_env` which stops repository rules and module extensions from inheriting the client environment (making `--repo_env=NAME` more than just an advisory notice).
When enabled up to 2 environment variables will still be forwarded (unless overridden or explicitly removed via `--repo_env==VARNAME`, see #26300 for more details);
- `PATH` - All platforms
- `PATHEXT` - Windows
See `test_execute_environment_strict_vars` in `src/test/shell/bazel/starlark_repository_test.sh` for a demonstration.
Note that the behavior is different to the similarly named `--incompatible_strict_action_env`, which stops _all_ environment variables (`--action_env` affects actions with `use_default_shell_env = True`) except those specified within the defining rule. This is by design as repository rules operate in an inherently non-hermetic domain, covering roles such as integrating with the C/C++ toolchain installed on the host. It does not make sense to lock down environment variables _by default_, this is best left up to individual projects and users.
This flag is marked experimental to allow for testing and requirement discovery (e.g. env vars other than `PATH` that should be included).
Closes #10996
Closes #24404.
PiperOrigin-RevId: 836494750
Change-Id: Ic05e5ca47a14badb2cd23f810e775c3341ddfaa8--experimental_strict_repo_env option1 parent 08bc4d7 commit 60bc017
20 files changed
Lines changed: 195 additions & 52 deletions
File tree
- src
- main/java/com/google/devtools/build/lib
- bazel
- bzlmod
- repository
- starlark
- runtime
- skyframe/packages
- starlarkbuildapi/repository
- test
- java/com/google/devtools/build/lib
- analysis/util
- bazel
- bzlmod
- repository
- starlark
- skyframe
- shell/bazel
Lines changed: 15 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
87 | 88 | | |
88 | 89 | | |
89 | 90 | | |
| |||
132 | 133 | | |
133 | 134 | | |
134 | 135 | | |
| 136 | + | |
| 137 | + | |
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
| |||
213 | 216 | | |
214 | 217 | | |
215 | 218 | | |
216 | | - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
217 | 223 | | |
218 | | - | |
| 224 | + | |
| 225 | + | |
219 | 226 | | |
220 | 227 | | |
221 | 228 | | |
| |||
278 | 285 | | |
279 | 286 | | |
280 | 287 | | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
281 | 294 | | |
282 | 295 | | |
283 | 296 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
58 | | - | |
| 58 | + | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
72 | | - | |
| 73 | + | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
| 88 | + | |
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
| |||
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
| 98 | + | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
| |||
141 | 144 | | |
142 | 145 | | |
143 | 146 | | |
| 147 | + | |
144 | 148 | | |
145 | 149 | | |
146 | 150 | | |
| |||
176 | 180 | | |
177 | 181 | | |
178 | 182 | | |
179 | | - | |
| 183 | + | |
180 | 184 | | |
181 | | - | |
| 185 | + | |
182 | 186 | | |
183 | 187 | | |
184 | 188 | | |
185 | 189 | | |
186 | 190 | | |
187 | | - | |
| 191 | + | |
188 | 192 | | |
| 193 | + | |
189 | 194 | | |
190 | 195 | | |
191 | 196 | | |
| |||
364 | 369 | | |
365 | 370 | | |
366 | 371 | | |
| 372 | + | |
367 | 373 | | |
368 | 374 | | |
369 | 375 | | |
| |||
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| |||
71 | 72 | | |
72 | 73 | | |
73 | 74 | | |
74 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
75 | 78 | | |
| 79 | + | |
76 | 80 | | |
77 | 81 | | |
78 | 82 | | |
| |||
124 | 128 | | |
125 | 129 | | |
126 | 130 | | |
| 131 | + | |
127 | 132 | | |
128 | 133 | | |
129 | 134 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| 107 | + | |
106 | 108 | | |
107 | 109 | | |
108 | 110 | | |
| 111 | + | |
109 | 112 | | |
110 | 113 | | |
111 | 114 | | |
| |||
607 | 610 | | |
608 | 611 | | |
609 | 612 | | |
| 613 | + | |
610 | 614 | | |
611 | 615 | | |
612 | 616 | | |
| |||
Lines changed: 25 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
158 | 158 | | |
159 | 159 | | |
160 | 160 | | |
161 | | - | |
| 161 | + | |
| 162 | + | |
162 | 163 | | |
163 | 164 | | |
164 | 165 | | |
| |||
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
183 | | - | |
| 184 | + | |
| 185 | + | |
184 | 186 | | |
185 | 187 | | |
186 | 188 | | |
| |||
191 | 193 | | |
192 | 194 | | |
193 | 195 | | |
194 | | - | |
195 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
196 | 199 | | |
197 | 200 | | |
198 | 201 | | |
| |||
823 | 826 | | |
824 | 827 | | |
825 | 828 | | |
826 | | - | |
| 829 | + | |
827 | 830 | | |
828 | 831 | | |
829 | 832 | | |
| |||
1063 | 1066 | | |
1064 | 1067 | | |
1065 | 1068 | | |
1066 | | - | |
| 1069 | + | |
1067 | 1070 | | |
1068 | 1071 | | |
1069 | 1072 | | |
| |||
1430 | 1433 | | |
1431 | 1434 | | |
1432 | 1435 | | |
1433 | | - | |
| 1436 | + | |
1434 | 1437 | | |
1435 | 1438 | | |
1436 | 1439 | | |
1437 | 1440 | | |
1438 | 1441 | | |
1439 | | - | |
| 1442 | + | |
1440 | 1443 | | |
1441 | | - | |
| 1444 | + | |
1442 | 1445 | | |
1443 | 1446 | | |
1444 | 1447 | | |
| |||
1911 | 1914 | | |
1912 | 1915 | | |
1913 | 1916 | | |
1914 | | - | |
| 1917 | + | |
1915 | 1918 | | |
1916 | | - | |
1917 | | - | |
1918 | | - | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
1919 | 1922 | | |
1920 | 1923 | | |
1921 | 1924 | | |
1922 | | - | |
| 1925 | + | |
1923 | 1926 | | |
1924 | | - | |
| 1927 | + | |
1925 | 1928 | | |
1926 | 1929 | | |
1927 | 1930 | | |
| |||
1930 | 1933 | | |
1931 | 1934 | | |
1932 | 1935 | | |
1933 | | - | |
| 1936 | + | |
| 1937 | + | |
1934 | 1938 | | |
1935 | 1939 | | |
1936 | 1940 | | |
| |||
1949 | 1953 | | |
1950 | 1954 | | |
1951 | 1955 | | |
1952 | | - | |
1953 | | - | |
| 1956 | + | |
| 1957 | + | |
1954 | 1958 | | |
1955 | 1959 | | |
1956 | 1960 | | |
| |||
1982 | 1986 | | |
1983 | 1987 | | |
1984 | 1988 | | |
1985 | | - | |
1986 | | - | |
| 1989 | + | |
| 1990 | + | |
1987 | 1991 | | |
1988 | 1992 | | |
1989 | 1993 | | |
| |||
2247 | 2251 | | |
2248 | 2252 | | |
2249 | 2253 | | |
2250 | | - | |
| 2254 | + | |
2251 | 2255 | | |
2252 | 2256 | | |
2253 | 2257 | | |
| |||
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
| 94 | + | |
94 | 95 | | |
95 | 96 | | |
96 | 97 | | |
| |||
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
106 | | - | |
| 107 | + | |
| 108 | + | |
107 | 109 | | |
108 | 110 | | |
109 | 111 | | |
| |||
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
338 | 351 | | |
339 | 352 | | |
340 | 353 | | |
| |||
347 | 360 | | |
348 | 361 | | |
349 | 362 | | |
| 363 | + | |
350 | 364 | | |
351 | 365 | | |
352 | 366 | | |
| |||
356 | 370 | | |
357 | 371 | | |
358 | 372 | | |
| 373 | + | |
359 | 374 | | |
360 | 375 | | |
361 | 376 | | |
| |||
981 | 996 | | |
982 | 997 | | |
983 | 998 | | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
984 | 1008 | | |
985 | 1009 | | |
986 | 1010 | | |
| |||
0 commit comments