bazel: Fix python stub template#66718
Conversation
The shebang in the python stub template was incorrectly patched to ``` <store-path>/bin/env python ``` instead of ``` <store-path>/bin/python ``` The reason was that `patchShebangs` was called with `--replace` which is an unknown argument. ``` patching script interpreter paths in src/main/java/com/google/devtools/build/lib/bazel/rules/python/python_stub_template.txt --replace /usr/bin/env python /nix/store/w7gsq8v86hni4ynaqgwwlnlny115ylng-python3-3.7.4/bin/python find: unknown predicate `--replace' ``` Using `substituteInPlace` instead resolves that issue. The wrong shebang caused failures of `py_binary` targets due to `python` not being in `PATH` in certain circumstances.
|
Notably, our tests didn’t catch that we introduced a broken path in the final bazel. We were able to find it by letting bazel self-extract and then grepping over the extracted repository, which found it in the main bazel I can provide instructions on how to implement such a test. cc @abbradar, this was originally introduced by https://github.com/NixOS/nixpkgs/pull/64903/files#diff-4746b81564a01e241a84d455575437e7R311 and slipped through review. |
|
@GrahamcOfBorg build bazel.tests |
c493cc7 to
e73a3d0
Compare
|
Thanks for fixing this! I don't like that it didn't fail because of unknown argument; I'll look into this in several weeks (will be busy at CCCamp ;) ). |
The shebang in the python stub template was incorrectly patched to
instead of
The reason was that
patchShebangswas called with--replacewhich isan unknown argument.
Using
substituteInPlaceinstead resolves that issue.Motivation for this change
The wrong shebang caused failures of
py_binarytargets due topythonnot being in
PATHin certain circumstances.Things done
sandboxinnix.confon non-NixOS)nix-shell -p nix-review --run "nix-review wip"./result/bin/)nix path-info -Sbefore and after)Notify maintainers
cc @Profpatsch