bazelbuild/bazel
View on GitHub`repository_ctx.watch_tree` attempts to watch invalid files in `.git` directories.
Open
#25,764 opened on Apr 3, 2025
P2help wantedteam-ExternalDepstype: feature request
Description
Description of the bug:
When using repository_ctx.watch_tree on a directory that contains a .git directory which has enabled core.fsmonitor, the .git directory may contain a .git/fsmonitor--daemon.ipc which is un-watchable and thus it fails with the following message:
File "/private/var/tmp/_bazel_lpadron/9ae9416857eb79bb978de35a53d54970/external/rules_swift_package_manager+/swiftpkg/internal/local_swift_package.bzl", line 20, column 34, in _list_contents
repository_ctx.watch_tree(path)
Error in watch_tree: java.io.FileNotFoundException: /Users/lpadron/Development/swift-command-line-tools/.git/fsmonitor--daemon.ipc (Operation not supported on socket)
Should we be watching .git directories at all?
Proposed solution:
- Respect
.bazelignorefrom the root module when usingwatch_tree - Respect
ignored_directoryfrom the root module when usingwatch_tree - Either always ignore
.gitdirectories inwatch_treeor add API towatch_treeto allow rule authors to set ignored directories.
Which category does this issue belong to?
External Dependency
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Attempt to watch_tree a git repository that has the fsmonitor daemon.
Which operating system are you running Bazel on?
macOS 15.4
What is the output of bazel info release?
8.1.1
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 ?
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