bazel: `fatal error: 'resolv.h' file not found` on macOS / nix
Description of the bug:
Hey there Bazel team! I’ve run into a issue that I can’t solve. I’m building a Go project with the following setup:
- macOS 14.7.1
- devenv 1.3.1
- Bazel 8.0.0
When trying to build my project, the resolv.h header can’t be found.
$ bazelisk build //hello
INFO: Analyzed target //hello:hello (104 packages loaded, 5659 targets configured).
ERROR: /private/var/tmp/_bazel_kyle/c3d7894f4cdf3c1bcc4683dd549d8b70/external/rules_go~/BUILD.bazel:42:7: GoStdlib external/rules_go~/stdlib_/pkg failed: (Exit 1): builder failed: error executing GoStdlib command (from target @@rules_go~//:stdlib) bazel-out/darwin_arm64-opt-exec-ST-d57f47055a04/bin/external/rules_go~~go_sdk~devenv-bazel-go-broken__download_0/builder_reset/builder stdlib -sdk ... (remaining 13 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
# net/internal/cgotest
bazel-out/darwin_arm64-fastbuild/bin/external/rules_go~/stdlib_/src/net/internal/cgotest/resstate.go:10:10: fatal error: 'resolv.h' file not found
#include <resolv.h>
^~~~~~~~~~
1 error generated.
stdlib: error running subcommand external/rules_go~~go_sdk~devenv-bazel-go-broken__download_0/bin/go: exit status 1
Target //hello:hello failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 27.889s, Critical Path: 12.49s
INFO: 8 processes: 7 internal, 1 darwin-sandbox.
ERROR: Build did NOT complete successfully
I’m confident this is a strange interaction with between Bazel and Nix / devenv, but I’m not having much success figuring out what that interaction is. Would appreciate any help solving the issue!
Which category does this issue belong to?
C++ Rules
What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
This requires a nix installation and devenv.sh.
git clone https://github.com/kyleconroy/devenv-bazel-go-broken
cd devenv-bazel-go-broken
devenv shell
bazelisk build //hello
Which operating system are you running Bazel on?
macOS
What is the output of bazel info release?
release 8.0.0
If bazel info release returns development version or (@non-git), tell us how you built Bazel.
No response
What’s the output of git remote get-url origin; git rev-parse HEAD ?
git@github.com:kyleconroy/devenv-bazel-go-broken.git
11bd0e334a2ecc44e11ac0b81bdba922b6524640
If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.
No response
Have you found anything relevant by searching the web?
I’ve opened up an issue (https://github.com/cachix/devenv/issues/1099) on devenv, as I’m not sure where the bug is happening.
I ran into a similar bug back in April and found a few Bazel issues that might be related
- https://github.com/bazel-contrib/rules_go/issues/3793
- https://github.com/bazelbuild/bazel/issues/20638
Any other information, logs, or outputs that you want to share?
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 15 (2 by maintainers)
you could try with llvm@19. then setting flag :
build --action_env=CC=/opt/homebrew/opt/llvm@19/bin/clang build --action_env=CXX=/opt/homebrew/opt/llvm@19/bin/clang++ build --action_env=LDFLAGS=“-L/opt/homebrew/opt/llvm@19/lib” build --action_env=CPPFLAGS=“-I/opt/homebrew/opt/llvm@19/include”
I got this to work by unsetting the DEVELOPER_DIR, CC, and CXX environment variables