Skip to content

Make bazelrc importing a nonexistent file non-fatal #5765

Closed

Description

@perfinion

TensorFlow uses a ./configure script which writes to %workspace%/.tf_configure_bazelrc
I've filed tensorflow/tensorflow#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:
#4502
ec83598
#5756

Activity

  1. perfinion commented on Aug 4, 2018

    @perfinion
    Author

    @cvcal ping :)

  2. cvcal commented on Aug 7, 2018

    @cvcal
    Contributor

    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

  3. dapirian commented on Aug 7, 2018

    @dapirian

    I also consider this blocking for the rc file change. I need to have a place where we commit our bazelrc and a gitignored place where our devs can put their user-and-workspace specific configuration, if they desire.

  4. cvcal commented on Aug 7, 2018

    @cvcal
    Contributor

    I'll get started on this, got word from the release manager that we should be able to cherry-pick this in if needed

  5. dapirian commented on Aug 7, 2018

    @dapirian

    @cvcal Even better than import invisibly doing nothing if the file doesn't exist would be just looking for a .bazelrc.user on its own. Official support for commited and user specific config files, like there was before.

  6. jjudd commented on Aug 7, 2018

    @jjudd
    Contributor

    I agree with @dapirian. It would be great to, like before, have support for committed and user specific config files. Making importing non-existent files possible enables us to workaround the removal of tools/bazel.rc. However, that means that every Bazel project will need to introduce its own custom name and location for .bazelrc.user files. Having a standardized and documented .bazelrc.user file would be ideal.

  7. cvcal commented on Aug 7, 2018

    @cvcal
    Contributor

    The problem with this is that then Bazel is effectively requiring that this file be included in the gitignore file - do we currently have other files inside a Workspace that are standard but expected to not be shared?

  8. jjudd commented on Aug 7, 2018

    @jjudd
    Contributor

    The only one that we use regularly is .bazelrc. I'm not sure if there are others. It seems that any per user file is going to need to be gitignored.

  9. cvcal commented on Aug 7, 2018

    @cvcal
    Contributor

    K - afaiac, the old tools/blaze.rc and .bazelrc setup was a bug, not a feature, so I'm not going to take that as prior art :) However, you're right that if we accept that having per-user-&-per-workspace rcfiles is needed as a standard feature, this can't very well be avoided.

    I feel ok keeping both given the number of responses about this issue - but the old names still make no sense in this case. %workspace%/project.bazelrc and %workspace%/user.bazelrc would work for me.

    QQ to @perfinion - I don't want to add both an optional import and an additional rc file - I'm pretty sure, looking at the TF PR you linked in the original post, that the issue had to do with the re-appropriation of the %workspace%/.bazelrc name - so this should unblock you. Can you confirm?

  10. jjudd commented on Aug 7, 2018

    @jjudd
    Contributor

    100% agree that the old names made little sense. I like project.bazelrc and user.bazelrc. I am also in support of supporting per-user-&-per-workspace rcfiles. The Bazel projects I interact with are different enough that options that are relevant to our main codebase make little sense when interacting with other open source projects.

    Also agree that both optional import and the additional rc file do not seem necessary. Advantage of the additional rc file is that it is in a standard location. Advantage of optional imports is that any number of optional rc files can be used.

    Is there anything we can do to help?

  11. cvcal commented on Aug 7, 2018

    @cvcal
    Contributor

    No, but thanks - I've got the project/user split change already complete, I am just going to need a review and a confirmation from Jason that this will unblock TensorFlow

  12. jmmv commented on Aug 8, 2018

    @jmmv
    Contributor

    The way I have seen this done in other build systems is as hinted above: have the "silent include" feature as a distinct statement so that it's obvious that this may fail. Then, your project checks in something like:

    # .bazelrc
    silent-import "%workspace%/.bazelrc.user"
    ... project-specific settings ...
    

    Then you can ignore the file unconditionally by checking in the configuration as well:

    # .gitignore (and IDE configuration, whatever)
    .bazelrc.user
    

    And then your ./configure file can simply create .bazelrc.user and get things to work automatically.

    No additional complexity in the build tool to recognize one more possible configuration file, and therefore, no need to enforce a strange location (like tools/bazel.rc) on users. This is such a niche use case, easily implemented with a trivial silent-import primitive, that adding the extra logic of an additional rc file to Bazel's core seems suboptimal...

    The way rc files work today is already too complicated due to the multiple locations, so I think it makes more sense to push any other complexity to the few projects that may need it. (I believe that the existence of a configure script is also a kludge. Ideally, whatever such a script does should be handled by Bazel proper in the future, which means that implementing extra features to support that today might not be great in the long term.)

  13. perfinion commented on Aug 8, 2018

    @perfinion
    Author

    @cvcal yeah some kind of project vs user rc file would work, or a import-nonfatal. I do not have any strong preference either way.

    My only concern is that TF has a configure step and I don't want that file accidentally committed to the repo since that would break other people. I will fix up TensorFlow to work with whatever way you pick.

    @case540 @gunan just to check, do you guys have any preference?

  14. cvcal commented on Aug 8, 2018

    @cvcal
    Contributor

    @jmmv - yes, that was the original request, silent-import, import-nonfatal, whatever you name it.

    As far as I am concerned, the import-nonfatal statement and the standardized custom rc location both work. I feel that standardization is useful for onboarding users and projects, since it makes it easy to say where certain settings can go, and it has the advantage of not reusing the old workspace/.bazelrc file, which is causing some migration pain. OTOH, import-nonfatal is more general, allows users to do whatever they want, but more power comes with more risk - chains of silent-imports would be a pain to debug if anyone is having issues.

  15. case540 commented on Aug 8, 2018

    @case540

    Any of these options sounds fine with me. But yeah, for TensorFlow at the moment, we need one place to add default bazelrc configs that are checked in to the repo (currently tools/bazel.rc). And we need another place for generated configs to be dumped to (currently .bazelrc) that should not be checked in.

    I like the idea of non-fatal import option personally.

  16. cvcal commented on Aug 15, 2018

    @cvcal
    Contributor

    I was working on the non-fatal import option when I realized that it might encourage the likelihood of double-includes: If a standard location like %workspace%/my.bazelrc starts getting used in different projects with an optional-import, but not all projects use it, users who've gotten used to the set up will likely end up importing the file from their home-rc so that they can have a custom configuation for other projects, and then you have potentially two files loading the same set of options. This would lead to duplicates in options that accept multiple values - usually not a problem but which has been known to annoy people in the past. It can be a problem if the repeated options (often used for compiler options, as in --copt) then gets passed to some tool that does care about repeat values.

  17. added 2 commits that reference this issue on Aug 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions