Renaming package name causes failure when watchfs in enabled on macos
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
When renaming packages from mixedcase to lowercase with the watchfs flag enabled, bazel will attempt to build almost identical targets twice with the only difference being the casing. This seems to only occur when the watchfs flag is enabled.
Note the case difference in the attached logs, fooBar vs foobar.
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
1. Clone https://github.com/anthonyjpratti/bazel-case-insensitive-watchfs-bug
2. Run `bazel build //java/com/example/...`
3. Switch to `bug` branch, run `bazel build //java/com/example/...`
4. Switch back to main, run `bazel build //java/com/example/...`
N.B. it doesn't happen every time, sometimes it takes a few tries to get it to error, which become more reliable with the `--spawn_strategy=remote,local` and `--strategy=Javac=worker` flags.
### Which operating system are you running Bazel on?
Macos
### What is the output of `bazel info release`?
release 5.4.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 master; git rev-parse HEAD` ?
_No response_
### Have you found anything relevant by searching the web?
Looks related to https://github.com/bazelbuild/bazel/issues/6401
### Any other information, logs, or outputs that you want to share?
```
SUBCOMMAND: # //java/com/example/fooBar:fooBar [action 'Building java/com/example/fooBar/libfooBar.jar (1 source file)', configuration: 8c7c8a83495a6b29f5e61b94373e857884c6b6f4ed04fcd868a9a81a5d062e34, execution platform: @local_config_platform//:host]
(cd /private/var/tmp/_bazel_USER/f04a15a071974e2d44ffb3151e38b855/execroot/__main__ && \
exec env - \
LC_CTYPE=en_US.UTF-8 \
PATH=/Users/USER/Library/Caches/bazelisk/downloads/bazelbuild/bazel-5.4.0-darwin-arm64/bin:/Users/USER/.jabba/jdk/adopt@1.11.0-11/Contents/Home/bin:/opt/local/bin:/opt/local/sbin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/USER/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/USER/n/bin:/Users/USER/Library/Python/3.9/bin \
external/remotejdk11_macos_aarch64/bin/java -XX:-CompactStrings '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.resources=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED' '--add-opens=java.base/java.nio=ALL-UNNAMED' '--add-opens=java.base/java.lang=ALL-UNNAMED' '--patch-module=java.compiler=external/remote_java_tools/java_tools/java_compiler.jar' '--patch-module=jdk.compiler=external/remote_java_tools/java_tools/jdk_compiler.jar' -jar external/remote_java_tools/java_tools/JavaBuilder_deploy.jar @bazel-out/darwin_arm64-fastbuild/bin/java/com/example/fooBar/libfooBar.jar-0.params @bazel-out/darwin_arm64-fastbuild/bin/java/com/example/fooBar/libfooBar.jar-1.params)
# Configuration: 8c7c8a83495a6b29f5e61b94373e857884c6b6f4ed04fcd868a9a81a5d062e34
# Execution platform: @local_config_platform//:host
SUBCOMMAND: # //java/com/example/foobar:fooBar [action 'Building java/com/example/foobar/libfooBar.jar (1 source file)', configuration: 8c7c8a83495a6b29f5e61b94373e857884c6b6f4ed04fcd868a9a81a5d062e34, execution platform: @local_config_platform//:host]
(cd /private/var/tmp/_bazel_USER/f04a15a071974e2d44ffb3151e38b855/execroot/__main__ && \
exec env - \
LC_CTYPE=en_US.UTF-8 \
PATH=/Users/USER/Library/Caches/bazelisk/downloads/bazelbuild/bazel-5.4.0-darwin-arm64/bin:/Users/USER/.jabba/jdk/adopt@1.11.0-11/Contents/Home/bin:/opt/local/bin:/opt/local/sbin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/USER/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/USER/n/bin:/Users/USER/Library/Python/3.9/bin \
external/remotejdk11_macos_aarch64/bin/java -XX:-CompactStrings '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.resources=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED' '--add-opens=java.base/java.nio=ALL-UNNAMED' '--add-opens=java.base/java.lang=ALL-UNNAMED' '--patch-module=java.compiler=external/remote_java_tools/java_tools/java_compiler.jar' '--patch-module=jdk.compiler=external/remote_java_tools/java_tools/jdk_compiler.jar' -jar external/remote_java_tools/java_tools/JavaBuilder_deploy.jar @bazel-out/darwin_arm64-fastbuild/bin/java/com/example/foobar/libfooBar.jar-0.params @bazel-out/darwin_arm64-fastbuild/bin/java/com/example/foobar/libfooBar.jar-1.params)
# Configuration: 8c7c8a83495a6b29f5e61b94373e857884c6b6f4ed04fcd868a9a81a5d062e34
# Execution platform: @local_config_platform//:host
ERROR: /Users/USER/workspace/bazel-case-insensitive-watchfs-bug/java/com/example/foobar/BUILD:1:13: Building java/com/example/foobar/libfooBar.jar (1 source file) failed: (Exit 1): java failed: error executing command external/remotejdk11_macos_aarch64/bin/java -XX:-CompactStrings '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED' ... (remaining 17 arguments skipped)
INFO: Elapsed time: 0.133s, Critical Path: 0.02s
INFO: 4 processes: 4 internal.
FAILED: Build did NOT complete successfully
```
Contributor guide
Research direction
Reproduce the failure with `bazel build //java/com/example/...` while switching between the main and bug branches in the linked example repository. Start by inspecting `java/com/example/foobar/BUILD` and the watchfs handling around package renames. Done means the mixed-case to lowercase rename no longer causes duplicate targets or a failed build on macOS.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, macos
- Domain
- build-system, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100