Creating a git branch that ends in "BUILD" confuses Bazel
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 75
Description
### Description of the bug:
If you create a git branch like `ob/BUILD` or `ob/build` (on macOS where the file system is case insensitive) bazel thinks it's a build file and chokes on it.
### 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.
```shell
$ git init demo
$ cd demo
$ touch MODULE.bazel WORKSPACE
$ git add -A
$ git commit -am "init bazel repo"
[main (root-commit) f45e299] init bazel repo
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 MODULE.bazel
create mode 100644 WORKSPACE
$ git checkout -b ob/build
Switched to a new branch 'ob/build'
$ bazel build //...
ERROR: /Users/obonilla/tmp/demo/.git/logs/refs/heads/ob/BUILD:1:1: invalid octal literal: 0000000000000000000000000000000000000000 (use '0o000000000000000000000000000000000000000')
ERROR: /Users/obonilla/tmp/demo/.git/logs/refs/heads/ob/BUILD:1:42: syntax error at 'f45e29939884f14e45e1dac396a2534ce168ee1c': expected newline
ERROR: /Users/obonilla/tmp/demo/.git/logs/refs/heads/ob/BUILD:1:104: invalid character: '@'
ERROR: /Users/obonilla/tmp/demo/.git/logs/refs/heads/ob/BUILD:1:128: invalid octal literal: 0700 (use '0o700')
ERROR: /Users/obonilla/tmp/demo/.git/logs/refs/heads/ob/BUILD:1:149: keyword 'from' not supported
ERROR: /Users/obonilla/tmp/demo/.git/refs/heads/ob/BUILD:1:1: name 'f45e29939884f14e45e1dac396a2534ce168ee1c' is not defined
ERROR: package contains errors: .git/logs/refs/heads/ob
ERROR: package contains errors: .git/refs/heads/ob
WARNING: Target pattern parsing failed.
ERROR: Skipping '//...': Error evaluating '//...': error loading package '.git/logs/refs/heads/ob': Package '.git/logs/refs/heads/ob' contains errors
ERROR: Error evaluating '//...': error loading package '.git/logs/refs/heads/ob': Package '.git/logs/refs/heads/ob' contains errors
INFO: Elapsed time: 2.027s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
```
### Which operating system are you running Bazel on?
macOS
### What is the output of `bazel info release`?
release 7.3.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` ?
_No response_
### 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_
Contributor guide
Research direction
Reproduce the failure on macOS with a branch such as ob/build, then run bazel build //... in the demo repository. Inspect how Bazel interprets the mentioned .git/refs/heads/ob/BUILD and .git/logs/refs/heads/ob paths during package discovery. Done means builds no longer treat Git branch metadata as BUILD files.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100