You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make bazelrc importing a nonexistent file non-fatal #5765
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?
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
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.
@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.
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.
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?
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?
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.
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
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:
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-importprimitive, 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.)
@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?
@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.
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.
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.
Activity
perfinion commentedon Aug 4, 2018
@cvcal ping :)
cvcal commentedon Aug 7, 2018
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
dapirian commentedon Aug 7, 2018
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.
cvcal commentedon Aug 7, 2018
I'll get started on this, got word from the release manager that we should be able to cherry-pick this in if needed
dapirian commentedon Aug 7, 2018
@cvcal Even better than
importinvisibly doing nothing if the file doesn't exist would be just looking for a.bazelrc.useron its own. Official support for commited and user specific config files, like there was before.jjudd commentedon Aug 7, 2018
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.userfiles. Having a standardized and documented.bazelrc.userfile would be ideal.cvcal commentedon Aug 7, 2018
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?
jjudd commentedon Aug 7, 2018
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.cvcal commentedon Aug 7, 2018
K - afaiac, the old
tools/blaze.rcand.bazelrcsetup 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.bazelrcand%workspace%/user.bazelrcwould 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%/.bazelrcname - so this should unblock you. Can you confirm?jjudd commentedon Aug 7, 2018
100% agree that the old names made little sense. I like
project.bazelrcanduser.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?
cvcal commentedon Aug 7, 2018
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
jmmv commentedon Aug 8, 2018
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:
Then you can ignore the file unconditionally by checking in the configuration as well:
And then your
./configurefile can simply create.bazelrc.userand 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 trivialsilent-importprimitive, 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
configurescript 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.)perfinion commentedon Aug 8, 2018
@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?
cvcal commentedon Aug 8, 2018
@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.
case540 commentedon Aug 8, 2018
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.
cvcal commentedon Aug 15, 2018
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.bazelrcstarts 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.Add a warning if the same rc file is read multiple times.
Rollforward of 2d3adfb: Add a warning if the same rc file is read mul…