bazelbuild / bazelbuild/bazel

watchfs misses BUILD.bazel edits in an ignored dir that backs a local_path_override module

Open
#29,741 0 comments 0 reactions 0 assignees View on GitHub
area-Bzlmod team-Core type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Description of the bug:

With --watchfs on macOS, a directory that is listed in .bazelignore and also backs a module via local_path_override stops receiving file-change events. The external repo is a symlink (external/nested+ -> /nested), so Bazel still reads nested/BUILD.bazel, but its FileValue is never invalidated. After an edit, the cached size is stale, and the next package load fails:
```
ERROR: error loading package '@@nested+//': File '.../external/nested+/BUILD.bazel' is unexpectedly longer than 99 bytes)
```
(Shrinking the file gives the symmetric Unexpected short read.) `bazel shutdown` + rebuild clears it, so it looks like flaky, self-healing breakage.

This layout — nested local_path_override modules whose directories are ignored so the main repo doesn't claim them as its own packages — is, as far as we found, the normal (and for a single repository, the only) way to structure a multi-module project. So this affects a common setup, not an edge case.

### Which category does this issue belong to?

Core

### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

https://github.com/mfilippov/bazel-watchfs-issue — clone and run ./repro.sh (steps and expected output are in the README).

### Which operating system are you running Bazel on?

macOS (Apple Silicon)

### What is the output of `bazel info release`?

9.1.0

### If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

5674a2d8634782e3d94ff773da6dd87d4f0260e7

### Have you found anything relevant by searching the web?

No

### Any other information, logs, or outputs that you want to share?

Workarounds: on macOS, moving the ignore to REPO.bazel ignore_directories() avoids it. On Linux that does not help (ignore_directories() is skipped by the watcher too) — only --nowatchfs works. On both platforms, keeping local modules outside the workspace tree (local_path_override(path = "../nested")) avoids it: no ignore is needed and the files are checked as external repos regardless of --watchfs.

Contributor guide

Open the contributing guide

Research direction

Start with the linked bazel-watchfs-issue repository, run ./repro.sh, and read its README for the expected failure. Investigate the --watchfs handling of ignored directories and local_path_override modules around the reported regression commit 5674a2d8634782e3d94ff773da6dd87d4f0260e7. Done means BUILD.bazel edits invalidate the cached file value and the next package load succeeds without --nowatchfs.

Written by the indexing model from the issue text.

Assessment

Tech stack
build-system
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.