Skip to content

Track emulated symlinked directories recursively#29221

Open
abishekgiri wants to merge 2 commits intobazelbuild:masterfrom
abishekgiri:windows-symlink-invalidation-fix
Open

Track emulated symlinked directories recursively#29221
abishekgiri wants to merge 2 commits intobazelbuild:masterfrom
abishekgiri:windows-symlink-invalidation-fix

Conversation

@abishekgiri
Copy link
Copy Markdown
Contributor

@abishekgiri abishekgiri commented Apr 2, 2026

Summary

This change makes repository_ctx.symlink() record recursive invalidation inputs when a non-native symlink fallback targets a directory.

What Changed

  • keep the existing shallow file watch for emulated symlinks to files
  • record a recursive DirTree input for emulated symlinks to directories
  • factor the directory-tree recording into a shared helper used by both watch_tree() and the symlink fallback path
  • add focused unit coverage for emulated file and directory symlinks in StarlarkRepositoryContextTest

Root Cause

On filesystems where Bazel cannot create native symlinks, repository_ctx.symlink() falls back to behavior that still needs invalidation tracking. The fallback always recorded a File input, which is too shallow for directory targets because it only captures that the directory exists, not changes anywhere under the tree.

Impact

Directory-backed fallback symlinks can now invalidate repository contents correctly when files are added, removed, or modified under the source tree.

Testing

Tried locally:

  • bazel test //src/test/java/com/google/devtools/build/lib/bazel/repository/starlark:StarlarkTests --test_filter='.*EmulatedSymlink.*' --test_output=errors

Current local blocker:

  • analysis completed, but execution on this machine is blocked by an unaccepted Xcode license (xcrun failed with code 69 from apple_support)

@github-actions github-actions bot added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Apr 2, 2026
@abishekgiri abishekgiri marked this pull request as draft April 2, 2026 23:48
@abishekgiri
Copy link
Copy Markdown
Contributor Author

Updated the invalidation tracking so emulated symlinks to directories now record recursive inputs, while emulated file symlinks keep the existing shallow file watch. Added focused unit coverage for both cases. Local Bazel validation on this machine is still blocked by the Xcode license gate from apple_support.

@bharadwaj08-one
Copy link
Copy Markdown

@abishekgiri Could you please take a look at the failing checks?

@bharadwaj08-one bharadwaj08-one added awaiting-user-response Awaiting a response from the author and removed awaiting-review PR is awaiting review from an assigned reviewer labels Apr 3, 2026
@abishekgiri
Copy link
Copy Markdown
Contributor Author

@abishekgiri Could you please take a look at the failing checks?

I traced the failing presubmits from Buildkite build #32714 to one shared strict-deps issue in StarlarkRepositoryContextTest, not 15 unrelated failures.

The new test path references DirectoryTreeDigestValue, but StarlarkTests_lib was missing the direct dep on //src/main/java/com/google/devtools/build/lib/skyframe:directory_tree_digest_value. I pushed 6c4be441b0 to add that missing dep in src/test/java/com/google/devtools/build/lib/bazel/repository/starlark/BUILD.

A targeted local bazel test //src/test/java/com/google/devtools/build/lib/bazel/repository/starlark:StarlarkTests --test_filter='.*EmulatedSymlink.*' --test_output=errors no longer surfaces the strict-deps error. The remaining local blocker here is the machine-wide Xcode license issue (xcrun code 69), so I’m waiting on the fresh Buildkite rerun to confirm CI.

@bharadwaj08-one bharadwaj08-one added awaiting-review PR is awaiting review from an assigned reviewer and removed awaiting-user-response Awaiting a response from the author labels Apr 7, 2026
@meteorcloudy meteorcloudy requested a review from Wyverald April 8, 2026 15:20
@meteorcloudy
Copy link
Copy Markdown
Member

Please update PR description according to our PR template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants