bazel: Make bazelrc importing a nonexistent file non-fatal

TensorFlow uses a ./configure script which writes to %workspace%/.tf_configure_bazelrc I’ve filed https://github.com/tensorflow/tensorflow/pull/21374 to move the tools/bazel.rc to the workspace root.

If /.bazelrc contains import %workspace%/.tf_configure.bazelrc but the source is not configured then this is a fatal error (below). The problem is that the ./configure script will add the line automatically and people may commit it by mistake and then break the build for people who do not call ./configure (configuring is not required for TF).

$ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
[bazel INFO src/main/cpp/option_processor.cc:203] Looked for a system bazelrc at path '/etc/bazel.bazelrc', but none was found.
[bazel INFO src/main/cpp/option_processor.cc:259] Looking for master bazelrcs in the following three paths: /home/jason/code/venv/tf/tensorflow/tools/bazel.rc, , 
[bazel INFO src/main/cpp/rc_file.cc:53] Parsing the RcFile /home/jason/code/venv/tf/tensorflow/.bazelrc
[bazel INFO src/main/cpp/rc_file.cc:53] Parsing the RcFile /home/jason/code/venv/tf/tensorflow/.tf_configure.bazelrc
[bazel FATAL src/main/cpp/blaze.cc:1271] Unexpected error reading .blazerc file '/home/jason/code/venv/tf/tensorflow/.tf_configure.bazelrc'

Can there be a “tryimport /path” or “import-nonfatal /path” or something along those lines to use instead in /.bazelrc so the file does not need changing by ./configure?

Related: https://github.com/bazelbuild/bazel/issues/4502 https://github.com/bazelbuild/bazel/commit/ec83598cb6ee4136166bb562a24dc5dfa58921db https://github.com/bazelbuild/bazel/issues/5756

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 16 (11 by maintainers)

Commits related to this issue

Most upvoted comments

Simply making import statements lenient on the existence of the file could be very confusing if users think a file should be loaded - making it an error helps if there are issues with the path name, etc. import-nonfatal or similar could work, I agree.

However I think we’ve passed the cutoff for 0.17 features, and it sounds like you consider this blocking for the rc file change. Am I understanding correctly? @jin