Skip to content

fix(bazel): patch protobuf for NixOS PATH compatibility#104

Closed
janickm wants to merge 1 commit into
NVIDIA:mainfrom
janickm:fix-protobuf-nixos
Closed

fix(bazel): patch protobuf for NixOS PATH compatibility#104
janickm wants to merge 1 commit into
NVIDIA:mainfrom
janickm:fix-protobuf-nixos

Conversation

@janickm
Copy link
Copy Markdown
Collaborator

@janickm janickm commented May 8, 2026

Summary

  • Patches protobuf@29.1 embed_edition_defaults rule to add use_default_shell_env = True to its ctx.actions.run_shell() call
  • Without this, the action runs with an empty PATH, causing sed/cp not found errors on NixOS (where tools live in /nix/store, not /usr/bin)

Root Cause

Protobuf's _embed_edition_defaults_impl in editions/defaults.bzl uses ctx.actions.run_shell() without use_default_shell_env = True. In Bazel 8, this creates a hermetic action environment with no PATH at all — --action_env=PATH and --noincompatible_strict_action_env only apply to actions that opt in via use_default_shell_env. On NixOS there are no tools at standard FHS paths like /usr/bin/sed, so the build fails.

Changes

File Description
MODULE.bazel single_version_override for protobuf with the patch
bazel/protobuf/BUILD.bazel Exports the patch file
bazel/protobuf/protobuf_use_default_shell_env.patch One-line patch adding use_default_shell_env = True

Testing

  • bazel build //... — passes (912 actions)
  • bazel test --config=no-gpu //... — 25/28 pass (3 failures are pre-existing Python 3.8 + PyTorch libtorch_cpu.so incompatibility, unrelated)

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.
@janickm janickm marked this pull request as draft May 8, 2026 21:28
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 8, 2026

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.

@janickm
Copy link
Copy Markdown
Collaborator Author

janickm commented May 11, 2026

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 rules_proto dependency entirely.

Verified: full build, all 28 tests, and Waymo dataset conversion all pass with the new approach.

@janickm janickm closed this May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant