Using Bazel on Windows for compiling a local target that has a dependency on a target located in the network location
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
I plan to use a module that physically lives on a mapped network drive and is consumed by a local module, producing and linking a static C++ library.
Here is the setup for my experiment:
**Directory Structures for the local and network modules**
```
C:\bazel_local_module\
├── MODULE.bazel
├── BUILD.bazel
└── main.cc
```
```
Z:\bazel_network_module\
├── MODULE.bazel
├── BUILD.bazel
├── include\
│ └── network_lib.h
└── src\
└── network_lib.cc
```
**Local Module**
`C:\bazel_local_module\MODULE.bazel`
```
module(
name = "local_app",
version = "1.0.0",
)
bazel_dep(
name = "network_lib",
version = "1.0.0",
)
local_path_override(
module_name = "network_lib",
path = "Z:/bazel_network_module",
)
```
`C:\bazel_local_module\BUILD.bazel`
```
cc_binary(
name = "local_app",
srcs = ["main.cpp"],
deps = [
"@network_lib//:network_lib",
],
)
```
`C:\bazel_local_module\main.cpp`
```
#include
#include "network_lib.h"
int main() {
std::cout << network_message() << std::endl;
return 0;
}
```
**Network Module**
`Z:\bazel_network_module\MODULE.bazel`
```
module(
name = "network_lib",
version = "1.0.0",
)
```
`Z:\bazel_network_module\BUILD.bazel`
```
cc_library(
name = "network_lib",
srcs = ["src/network_lib.cc"],
hdrs = ["include/network_lib.h"],
includes = ["include"],
visibility = ["//visibility:public"],
)
```
`Z:\bazel_network_module\include\network_lib.h`
```
#pragma once
const char* network_message();
```
`Z:\bazel_network_module\src\network_lib.cc`
```
#include "network_lib.h"
const char* network_message() {
return "Hello from the network drive static library!";
}
```
Why do I face the following error with this setup? How can I further debug this failure?
```
C:\bazel_local_module>bazel shutdown
C:\bazel_local_module>bazel clean --expunge
Starting local Bazel server (9.0.0) and connecting to it...
INFO: Starting clean.
C:\bazel_local_module>bazel build //:local_app --sandbox_debug --subcommands
Starting local Bazel server (9.0.0) and connecting to it...
ERROR: fetching network_lib+: java.io.IOException: network_lib+ must create a directory
ERROR: Error computing the main repository mapping: error during computation of main repo mapping: network_lib+ must create a directory
Computing main repo mapping:
```
### Which category does this issue belong to?
Remote Execution
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Reproduction steps are shared in the bug description.
### Which operating system are you running Bazel on?
Windows 11
### What is the output of `bazel info release`?
release 9.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` ?
```text
I am using the win64 executable installed from bazel/releases.
```
### 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?
_No response_
### Any other information, logs, or outputs that you want to share?
_No response_
Contributor guide
Research direction
Reproduce the failure from C:\bazel_local_module with the shown MODULE.bazel and BUILD.bazel files, using the bazel build command and its --sandbox_debug and --subcommands flags. Start by tracing the local_path_override for the mapped Z: drive and the reported network_lib+ directory error. Done means identifying the Windows-specific failure and documenting a verified fix or a focused debugging result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- build-system, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100