Bazel: Bazel not a fan of git branch named "build"

Created on 1 Dec 2016  路  4Comments  路  Source: bazelbuild/bazel

Please provide the following information. The more we know about your system and use case, the more easily and likely we can help.

Description of the problem / feature request / question:

Bazel explodes if you have a git branch named "build", even if you're not on the branch at the time:

bazel build ...
ERROR: /Users/geoffreyi/deepmath/.git/logs/refs/heads/BUILD:1:81: invalid base-10 integer constant: 5e074e001f956f5d5c7abd3d137c13be1bc8fe82.
ERROR: /Users/geoffreyi/deepmath/.git/logs/refs/heads/BUILD:1:109: invalid character: '@'.
ERROR: /Users/geoffreyi/deepmath/.git/logs/refs/heads/BUILD:1:137: invalid base-8 integer constant: 0800.
ERROR: /Users/geoffreyi/deepmath/.git/logs/refs/heads/BUILD:1:42: syntax error at '0': expected newline.
ERROR: package contains errors: .git/logs/refs/heads.
ERROR: /Users/geoffreyi/deepmath/.git/refs/heads/BUILD:1:40: invalid base-10 integer constant: 5e074e001f956f5d5c7abd3d137c13be1bc8fe82.
ERROR: package contains errors: .git/refs/heads.
ERROR: package contains errors: tensorflow/tensorflow/core/distributed_runtime/rpc.
ERROR: error loading package 'tensorflow/tensorflow/core/distributed_runtime/rpc': Extension file not found. Unable to load file '//tensorflow:tensorflow.bzl': file doesn't exist or isn't a file.

If possible, provide a minimal example to reproduce the problem:

  1. Clone a git repo that uses bazel, such as bazel itself.
  2. git checkout -b build
  3. bazel build ...

Environment info

  • Operating System:

Darwin.

  • Bazel version (output of bazel info release):

release-0.4.0-homebrew

Have you found anything relevant by searching the web? (e.g. GitHub issues, email threads in the [email protected] archive)

Hard to search for bazel problems involving the keyword "build". :)

under investigation

Most helpful comment

Ok this is not a Bazel issue per se. The correct way to support that is to do the following:

cat <<EOF >.bazelrc
build --deleted_packages .git
EOF

to ignore the .git package.

We cannot fix all corner case for all version system so using custom .bazelrc file is the way to go.

All 4 comments

Hi Geoffrey,

I have tried to create a small project and build it in a branch named build and found no problem. I also had no problem to build various bazel sub-packages the way you described. Can you please provide more context and maybe a small example/project where the build fails with a build branch but not without it? I would also like to know what differences you are seeing between building with and without a build branch. Thanks.

Cheers,
Irina

You have to name the branch "BUILD" on Linux, OS X is case-insensitive. It creates a BUILD file in .git for the branch, which of course isn't a Bazel-format BUILD file.

@iirina Yep, I should have clarified: "build" == "BUILD" on Mac. I just confirmed that on linux a "BUILD" branch gives the same error. Here's tensorflow on Linux:

(master) beltrami:tensorflow% git checkout -b BUILD
Switched to a new branch 'BUILD'
(BUILD) beltrami:tensorflow% bazel build ...
ERROR: /usr/local/google/home/geoffreyi/tensorflow/.git/refs/heads/BUILD:1:1: name 'dfc5cd48a095b133ece9caff663e3cc512e8a268' is not defined.
ERROR: package contains errors: .git/refs/heads.
ERROR: /usr/local/google/home/geoffreyi/tensorflow/.git/logs/refs/heads/BUILD:1:109: invalid character: '@'.
ERROR: /usr/local/google/home/geoffreyi/tensorflow/.git/logs/refs/heads/BUILD:1:137: invalid base-8 integer constant: 0800.
ERROR: /usr/local/google/home/geoffreyi/tensorflow/.git/logs/refs/heads/BUILD:1:42: syntax error at 'dfc5cd48a095b133ece9caff663e3cc512e8a268': expected newline.
ERROR: /usr/local/google/home/geoffreyi/tensorflow/.git/logs/refs/heads/BUILD:1:155: keyword 'from' not supported.
ERROR: package contains errors: .git/logs/refs/heads.
ERROR: error loading package '.git/logs/refs/heads': Package '.git/logs/refs/heads' contains errors.
INFO: Elapsed time: 0.418s

Ok this is not a Bazel issue per se. The correct way to support that is to do the following:

cat <<EOF >.bazelrc
build --deleted_packages .git
EOF

to ignore the .git package.

We cannot fix all corner case for all version system so using custom .bazelrc file is the way to go.

Was this page helpful?
0 / 5 - 0 ratings