Repository navigation
bazel_8: Add crucial packages to the standard shell environment - #489519
Conversation
fa5c161 to
b75357a
Compare
| gnused | ||
| gnutar | ||
| gzip | ||
| python3 |
There was a problem hiding this comment.
could you provide more details about when exactly this helps? Similar to #464436 (comment)
There was a problem hiding this comment.
rules_python uses the system python3 to bootstrap calling the python interpreter of py_binary(). So that makes calls to py_binary() outputs fail without a system Python.
Independent of that, like the other coreutils many projects assume python3 as a standard component available on the system. So without this, a lot of projects are excluded, thus putting it in the minimal environment is needed.
There was a problem hiding this comment.
I know, since we like hermetic systems, we all would like bazel to be more hermetic, but currently it isn't, so this is why we need these dependencies.
I am actively working towards bazel being more hermetic that expects the minimum from the host system (e.g. I will make a way to have the bazel CI also provide a nix platform, and am talking with a bunch of maintainers to get their rules_* more compliant).
So hopefully in the future, we can reduce the minium dependencies.
But as of today, bazel and many rules_* as well as projects are not there yet, and until then, we have to provide the dependencies that are commonly needed. There are more projects using bazel 8 now, but currently as a user, bazel_8 on Nix is not useful due to the removal of bash and python3.
There was a problem hiding this comment.
Amazing news! Do you have some link to this initiative that could be added as a comment to this list?
But I still would love to see examples I could reproduce (doesn't have to be exhaustive list of cases that fail, just some that fail, if issue is common shouldn't be hard to collect?).
For rules_python a bit inconclusive, docs still refer to system python needed for bootstrap, but otoh bazel-contrib/rules_python#1929 is merged
For bash also would be good to have an example (additional fun is whether bash in the list should be the hacked bash or upstream(ok, nixpkgs version of) bash)
There was a problem hiding this comment.
Can try to play with rules_python&rules_shell myself, but original use-case/setup would be even better
There was a problem hiding this comment.
Currently, I am working on a somewhat big project, so I don't have a small use-case.
The following might take a while to compile
https://github.com/The-OpenROAD-Project/OpenROAD
(comment out "@llvm_toolchain//:all" in MODULE.bazel as that is not compatible with nix; just use pkgs.clang19Stdenv)
Here is an example of a target that is a broken: the py_test() and requires both, python3 (to bootstrap that test and bash (bazel_tools/tools/test/generate-xml.sh))
bazel test -c opt //src/gpl/test:simple08
As I said, for now we should focus to support existing projects, and I work in the background to make the bazel and the whole infrastructure better in non-leaky hermeticity (e.g. getting Nix as a CI platform on bazel central registry).
Nothing is helped if we have a 'pure' bazel, but that is not usable in practice - in particular since we all want to encourage people working more towards using hermetic tools.
There was a problem hiding this comment.
I created a simple reproduction in https://github.com/hzeller/bazel-python-test
There was a problem hiding this comment.
Repro works for me too, and with bazel test --@rules_python//python/config_settings:bootstrap_impl=script ... it fails with
Executing tests from //:some_test
-----------------------------------------------------------------------------
Could not start dynamically linked executable: ...../execroot/_main/bazel-out/k8-fastbuild/bin/some_test.runfiles/_main/_some_test.venv/bin/python3
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld
which is another can of worms of even hermetic rules compatibility with NixOS without FHS wrapper..
Will have a little closer look. Also maybe this default shell could be runtime-parameterized for faster investigation&experimentation in future (and maybe that even could be submitted upstream)
There was a problem hiding this comment.
Yes, it would be neat if there was a config that would allow to provide an [ pkgs.foo pkgs.bar ] list.
(after this is PR is in, as it complements the needed basics)
| # ], | ||
| # ) | ||
| [ | ||
| bash |
There was a problem hiding this comment.
and for this one what's a rough issue repro scenario?
There was a problem hiding this comment.
I have seen it a bunch of times, e.g. with the OpenROAD test above (that hits both, the python3 and the bash problem
So even with python3 enabled but no bash, the following will fail:
bazel test -c opt //src/gpl/test:simple08
There was a problem hiding this comment.
took some time to clone-checkout-build but repro-ed this one too 👍
$ bazel build @@sed+//:lib/stdlib_h_inline
...
ERROR: ...../external/sed+/BUILD.bazel:108:15: RunBinary external/sed+/lib/stdlib.h failed: (Exit 127): inline_bin.sh failed: error executing RunBinary command (from target @@sed+//:lib/stdlib_h_inline) bazel-out/k8-opt-exec-ST-d57f47055a04/bin/external/sed+/inline_bin.sh bazel-out/k8-opt/bin/external/sed+/lib/stdlib.h.pre_inline bazel-out/k8-opt/bin/external/sed+/lib/stdlib.h ... (remaining 10 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
env: 'bash': No such file or directoryand that target definition is
external/sed+/BUILD.bazel:108:15
run_binary(
name = "lib/stdlib_h_inline",
tool = "@@sed+//:inline_sh",
srcs = ["@@sed+//:lib/stdlib.h.pre_inline", "@@sed+//:lib/_Noreturn.h", "@@sed+//:lib/arg-nonnull.h", "@@sed+//:lib/c++defs.h", "@@sed+//:lib/static_assert.h", "@@sed+//:lib/warn-on-use.h"],
outs = ["@@sed+//:lib/stdlib.h"],
args = ["$(execpath lib/stdlib.h.pre_inline)", "$(execpath lib/stdlib.h)", "$(execpath lib/arg-nonnull.h)", "definition of _GL_ARG_NONNULL", "$(execpath lib/warn-on-use.h)", "definition of _GL_WARN_ON_USE", "$(execpath lib/_Noreturn.h)", "definition of _Noreturn", "$(execpath lib/c++defs.h)", "definitions of _GL_FUNCDECL_RPL", "$(execpath lib/static_assert.h)", "definition of static_assert"],
)in turn @@sed+//:inline_sh is just a script with #!/usr/bin/env bash, it can be run via bazel run but fails in build action. Don't see a quick workaround here, well, except for
$ bazel build --action_env=PATH=/run/current-system/sw/bin @@sed+//:lib/stdlib_h_inlineNot sure yet this should be recommended, so adding some bash would be a path for now..
|
Ready to approve ? (I really would like to use bazel 8 without having to maintain local patches to my nixpkgs :) ). I think after that (if you're interested) we should start discussing how we can make the bazel world more pleasant to use
(e.g. I want to carve out some time to get Nix as a CI platform that is used for BCR bazelbuild/continuous-integration#2460 ) |
|
Would love to see this merged too! |
b75357a to
30162d5
Compare
A lot of parts of bazel and standard packages ssume bash existence; they should be able to call `/usr/bin/env bash`. Also, `rules_python` uses python3 as a bootstrap way to call other scripts (even if it uses its own interpreter). Both of these are important and have been in the bazel 7 package https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/ba/bazel_7/package.nix#L87-L104 ... but got lost in the bazel_8 package. Things that used to compile with bazel 7 now break with bazel 8 on nix. So: re-adding these crucial packages to the shell environment bazel has available when executing actions.
30162d5 to
1b7bce4
Compare
|
Adding @samuela as we need someone who has the merge bit, and you were recently involved in other bazel-related merges. |
|
I am not familiar with the details of this PR, but I will merge noting @boltzmannrain has approved it and is a maintainer for the derivation |
A lot of parts of bazel and standard packages ssume bash existence; they should be able to call
/usr/bin/env bash.Also,
rules_pythonuses python3 as a bootstrap way to call other scripts (even if it uses its own interpreter).Both of these are important and have been in the
bazel 7 package
https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/ba/bazel_7/package.nix#L87-L104
... but got lost in the bazel_8 package.
Things that used to compile with bazel 7 now break with bazel 8 on nix.
So: re-adding these crucial packages to the shell environment bazel has available when executing actions.
Things done
passthru.tests.nixpkgs-reviewon this PR. See nixpkgs-review usage../result/bin/.