Skip to content

Avoid depending on coreutils in bazel shell actions (NixOS compatibility) - #29510

Open
nicdumz wants to merge 3 commits into
protocolbuffers:mainfrom
nicdumz:avoid-coreutils-deps-bootstrap
Open

Avoid depending on coreutils in bazel shell actions (NixOS compatibility)#29510
nicdumz wants to merge 3 commits into
protocolbuffers:mainfrom
nicdumz:avoid-coreutils-deps-bootstrap

Conversation

@nicdumz

@nicdumz nicdumz commented Aug 29, 2026

Copy link
Copy Markdown
  • Bazel run_shell/genrule actions with no declared env/PATH inherit an empty action environment. On systems without an FHS-style /bin:/usr/bin (e.g. NixOS), bash's compiled-in fallback PATH doesn't resolve coreutils binaries like grep, cat, or dirname, even though bash itself is found via an explicit toolchain path.
  • ProtocAuthenticityCheck's shell action used grep/cat for a version check; replaced with a single read plus bash [[ ]] pattern matching and echo, so it depends only on bash builtins.
  • bootstrap_compiler.bzl's _extra_proto_path built a -I flag via $$(dirname $(location ...)); replaced with bash parameter expansion (${var%/*}) over a variable assigned earlier in the same command, again depending only on bash builtins.

@google-cla

google-cla Bot commented Aug 29, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

…ell action

ProtocAuthenticityCheck's run_shell action runs unqualified with no
declared env/PATH, so it inherits an empty action environment. On systems
without an FHS-style /bin:/usr/bin (e.g. NixOS), bash's compiled-in
fallback PATH doesn't resolve 'grep' or 'cat', and the action fails with
'command not found' even though bash itself was found via an explicit
toolchain path.

Replace grep/cat with a single 'read' plus bash's [[ ]] pattern matching
and 'echo', so the version check only depends on bash builtins.
…strap protoc invocation

_extra_proto_path builds a -I flag via $$(dirname $(location ...)),
run inside a genrule shell action with no declared env/PATH. On systems
without an FHS-style /bin:/usr/bin (e.g. NixOS), this fails with
'dirname: command not found'.

Replace it with bash parameter expansion (${var%/*}) over a variable
assigned earlier in the same command, so the path directory-name
computation depends only on bash builtins.
@nicdumz
nicdumz force-pushed the avoid-coreutils-deps-bootstrap branch from 9adc122 to ec2c07b Compare August 29, 2026 13:41
@nicdumz
nicdumz marked this pull request as ready for review August 29, 2026 13:57
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