Commit 1c303c7
bazel-hermetic: tolerate custom bazel wrappers; pure-bash env lookup; require HOME
Three findings from the latest Gemini pass, all on etc/bazel-hermetic:
- Custom (non-bazelisk) bazel wrappers no longer hard-fail. A wrapper
script starts with #!, so it entered the bazelisk-resolution block and
then exited 1 when no bazelisk-managed binary was found under the cache.
Now it warns and uses the wrapper directly; if the wrapper's interpreter
is not on the pruned PATH the launch fails on its own, which beats
refusing to run for everyone with a custom wrapper. (That error path was
in fact unreachable before: the failing `cat "${meta}"` aborted the
`real=` assignment under set -e; guarded with `|| true`.)
- Environment preservation uses a pure-bash `eval "value=\${$var:-}"`
instead of `printenv "$var"`: no subprocess per variable, and no silent
loss of proxy/SSH/TLS vars if printenv is off PATH. Names come from the
fixed list, never input, so eval is not an injection surface. Still
bash-3.2-safe (no ${!var}/-v).
- HOME uses ${HOME:?...}: fail early with a clear message if HOME is
unset/empty (bazel needs it for caches and user bazelrc) rather than
passing an empty HOME. Also satisfies the earlier set -u concern.
Re-verified with the stub-bazel harness: normal ELF path, the bug/info
paths, an empty-HOME early exit, and a non-bazelisk shebang wrapper now
warning and running.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>1 parent 8616be0 commit 1c303c7
1 file changed
Lines changed: 25 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
116 | 127 | | |
117 | 128 | | |
118 | 129 | | |
| |||
172 | 183 | | |
173 | 184 | | |
174 | 185 | | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
181 | 192 | | |
182 | 193 | | |
183 | 194 | | |
| |||
206 | 217 | | |
207 | 218 | | |
208 | 219 | | |
209 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
210 | 223 | | |
211 | | - | |
| 224 | + | |
212 | 225 | | |
213 | 226 | | |
214 | 227 | | |
| |||
0 commit comments