The PATH environment variable on my NixOS machine contains an element with an equal sign /nix/store/b0d9h0z581lh8ibcmmj99f2sgd1ax934-hyprland-qtutils-0.1.4+date=2025-06-19_b13c748/bin
When invoking bazel through bazelisk, the original PATH is omitted and will cause problems during the build.
For example in the bazel examples project (https://github.com/bazelbuild/examples) it will fail to determine the cc toolchain
bazelisk run //main:hello-world
INFO: Invocation ID: 2d4aebb2-30fa-4cd2-867d-a0acb8037bd1
INFO: Repository rules_cc++cc_configure_extension+local_config_cc instantiated at:
<builtin>: in <toplevel>
Repository rule cc_autoconf defined at:
/home/harald/.cache/bazel/_bazel_harald/40c32e8b4dc9eee77c2b5b1adbc3d365/external/rules_cc+/cc/private/toolchain/cc_configure.bzl:109:30: in <toplevel>
ERROR: /home/harald/.cache/bazel/_bazel_harald/40c32e8b4dc9eee77c2b5b1adbc3d365/external/rules_cc+/cc/private/toolchain/lib_cc_configure.bzl:112:9: An error occurred during the fetch of repository 'rules_cc++cc_configure_extension+local_config_cc':
Traceback (most recent call last):
File "/home/harald/.cache/bazel/_bazel_harald/40c32e8b4dc9eee77c2b5b1adbc3d365/external/rules_cc+/cc/private/toolchain/cc_configure.bzl", line 91, column 33, in cc_autoconf_impl
configure_unix_toolchain(repository_ctx, cpu_value, overriden_tools)
File "/home/harald/.cache/bazel/_bazel_harald/40c32e8b4dc9eee77c2b5b1adbc3d365/external/rules_cc+/cc/private/toolchain/unix_cc_configure.bzl", line 365, column 17, in configure_unix_toolchain
cc = find_cc(repository_ctx, overridden_tools)
File "/home/harald/.cache/bazel/_bazel_harald/40c32e8b4dc9eee77c2b5b1adbc3d365/external/rules_cc+/cc/private/toolchain/unix_cc_configure.bzl", line 321, column 23, in find_cc
cc = _find_generic(repository_ctx, "gcc", "CC", overridden_tools)
File "/home/harald/.cache/bazel/_bazel_harald/40c32e8b4dc9eee77c2b5b1adbc3d365/external/rules_cc+/cc/private/toolchain/unix_cc_configure.bzl", line 308, column 32, in _find_generic
auto_configure_fail(msg)
File "/home/harald/.cache/bazel/_bazel_harald/40c32e8b4dc9eee77c2b5b1adbc3d365/external/rules_cc+/cc/private/toolchain/lib_cc_configure.bzl", line 112, column 9, in auto_configure_fail
fail("\n%sAuto-Configuration Error:%s %s\n" % (red, no_color, msg))
Error in fail:
Auto-Configuration Error: Cannot find gcc or CC; either correct your path or set the CC environment variable
ERROR: no such package '@@rules_cc++cc_configure_extension+local_config_cc//':
Auto-Configuration Error: Cannot find gcc or CC; either correct your path or set the CC environment variable
ERROR: /home/harald/projects/bazel/examples/cpp-tutorial/stage1/main/BUILD:3:10: //main:hello-world depends on @@rules_cc++cc_configure_extension+local_config_cc//:cc-compiler-k8 in repository @@rules_cc++cc_configure_extension+local_config_cc which failed to fetch. no such package '@@rules_cc++cc_configure_extension+local_config_cc//':
Auto-Configuration Error: Cannot find gcc or CC; either correct your path or set the CC environment variable
ERROR: Analysis of target '//main:hello-world' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.111s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
ERROR: Build failed. Not running target
The error seems to be in the prependDirToPathListFunction which wouldn't find the PATH with extra '='s :
https://github.com/bazelbuild/bazelisk/blob/master/core/core.go#L653-L656
I'll submit a PR to fix the issue.
The PATH environment variable on my NixOS machine contains an element with an equal sign
/nix/store/b0d9h0z581lh8ibcmmj99f2sgd1ax934-hyprland-qtutils-0.1.4+date=2025-06-19_b13c748/binWhen invoking bazel through bazelisk, the original PATH is omitted and will cause problems during the build.
For example in the bazel examples project (https://github.com/bazelbuild/examples) it will fail to determine the cc toolchain
The error seems to be in the
prependDirToPathListFunctionwhich wouldn't find the PATH with extra '='s :https://github.com/bazelbuild/bazelisk/blob/master/core/core.go#L653-L656
I'll submit a PR to fix the issue.