fix(bazel): patch protobuf for NixOS PATH compatibility#104
Closed
janickm wants to merge 1 commit into
Closed
Conversation
Protobuf's embed_edition_defaults rule uses ctx.actions.run_shell() without use_default_shell_env=True, which creates a hermetic action environment with no PATH. On NixOS, tools like sed and cp live in /nix/store and are not available at /usr/bin, causing the build to fail with 'sed: command not found'. Add a single_version_override patch for protobuf@29.1 that sets use_default_shell_env=True on the offending action, allowing it to pick up PATH from --action_env=PATH in .bazelrc.user.
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
1 task
Collaborator
Author
|
Closing in favor of #105 which takes the cleaner approach: instead of patching protobuf 29.1, it bumps to protobuf 30.0 (which fixes the NixOS issue upstream) and also removes the archived Verified: full build, all 28 tests, and Waymo dataset conversion all pass with the new approach. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
embed_edition_defaultsrule to adduse_default_shell_env = Trueto itsctx.actions.run_shell()callPATH, causingsed/cpnot found errors on NixOS (where tools live in/nix/store, not/usr/bin)Root Cause
Protobuf's
_embed_edition_defaults_implineditions/defaults.bzlusesctx.actions.run_shell()withoutuse_default_shell_env = True. In Bazel 8, this creates a hermetic action environment with noPATHat all —--action_env=PATHand--noincompatible_strict_action_envonly apply to actions that opt in viause_default_shell_env. On NixOS there are no tools at standard FHS paths like/usr/bin/sed, so the build fails.Changes
MODULE.bazelsingle_version_overridefor protobuf with the patchbazel/protobuf/BUILD.bazelbazel/protobuf/protobuf_use_default_shell_env.patchuse_default_shell_env = TrueTesting
bazel build //...— passes (912 actions)bazel test --config=no-gpu //...— 25/28 pass (3 failures are pre-existing Python 3.8 + PyTorchlibtorch_cpu.soincompatibility, unrelated)