Skip to content

Commit 9ad05c9

Browse files
local_crate_repository: symlink to realpath on Windows
Bazel ≥ 9.0.1 replants workspace symlinks as relative `..\_main\...` paths that resolve at the output_base but not in the action execroot's `external/` (there is no `external/_main`). Using `entry.realpath` on Windows ensures each action sees the source files directly.
1 parent 804a0bf commit 9ad05c9

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

rs/private/crate_repository.bzl

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,13 @@ def _local_crate_repository_impl(rctx):
8989
if not root.exists:
9090
fail("crate path %s does not exist" % rctx.attr.path)
9191

92+
# On Windows, Bazel >= 9.0.1 replants workspace symlinks as relative
93+
# `..\_main\...` paths that resolve at the output_base but not in the
94+
# action execroot's `external/` (there is no `external/_main`). Symlink
95+
# to the realpath instead so each action sees the source files directly.
96+
is_windows = rctx.os.name.lower().startswith("windows")
9297
for entry in root.readdir():
93-
rctx.symlink(entry, entry.basename)
98+
rctx.symlink(entry.realpath if is_windows else entry, entry.basename)
9499

95100
patch(rctx)
96101

@@ -99,7 +104,7 @@ def _local_crate_repository_impl(rctx):
99104
rctx.file("BUILD.bazel", _generate_build_file(rctx, cargo_toml))
100105

101106
return rctx.repo_metadata(
102-
reproducible = bazel_features.external_deps.repo_rules_relativize_symlinks,
107+
reproducible = bazel_features.external_deps.repo_rules_relativize_symlinks and not is_windows,
103108
)
104109

105110
local_crate_repository = repository_rule(

0 commit comments

Comments
 (0)