Skip to content

Nightly: breakages from bazelrc read order changes #5756

Closed

Description

@jin

Build: https://buildkite.com/bazel/bazel-with-downstream-projects-bazel/builds/368

Issue: Change where bazelrcs are read from, and make it easier to control which ones are read.

Gerrit: 16.04, macOS

WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
  | /var/lib/buildkite-agent/builds/buildkite-worker-ubuntu1604-java8-ggpl-1/bazel-downstream-projects/gerrit/tools/bazel.rc

rules_jsonnet:

WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
  | /Users/buildkite/builds/buildkite-imacpro-2-1/bazel-downstream-projects/rules_jsonnet/tools/bazel.rc

rules_go:

WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
  | /Users/buildkite/builds/buildkite-imacpro-10-1/bazel-downstream-projects/rules_go/tools/bazel.rc

rules_typescript:

WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
  | /var/lib/buildkite-agent/builds/buildkite-worker-ubuntu1604-java8-mhj7-1/bazel-downstream-projects/rules_typescript/tools/bazel.rc

rules_nodejs:

WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
  | /Users/buildkite/builds/buildkite-imacpro-2-1/bazel-downstream-projects/rules_nodejs/tools/bazel.rc

rules_sass:

WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
  | /Users/buildkite/builds/buildkite-imacpro-9-1/bazel-downstream-projects/rules_sass/tools/bazel.rc

rules_scala:

WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
  | /Users/buildkite/builds/buildkite-imacpro-6-1/bazel-downstream-projects/rules_scala/tools/bazel.rc

BUILD_file_generator

WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files:
  | /Users/buildkite/builds/buildkite-imacpro-2-1/bazel-downstream-projects/BUILD_file_generator/tools/bazel.rc

Activity

  1. added
    P1
    on Aug 3, 2018
  2. cvcal commented on Aug 3, 2018

    @cvcal
    Contributor

    These breakages are intentional, and (as I argued in issue #4502) unavoidable. The change at fault is this: ec83598cb6ee4136166bb562a24dc5dfa58921dbT

    Copying over the relevant description from the root cause commit:

    The old list of bazelrcs was, in order:

    • %workspace%/tools/bazel.rc (unless --nomaster_bazelrc)
    • %binary_dir%/bazel.bazelrc (unless --nomaster_bazelrc)
    • system rc, /etc/bazel.bazelrc or in %ProgramData% for Windows (unless --nomaster_bazelrc)
    • the first of the following gets called the "user" bazelrc
      • path passed by flag --bazelrc
      • %workspace%/.bazelrc
      • $HOME/.bazelrc

    The new list is hopefully a bit more consistent, as:

    • system rc (unless --nosystem_rc) (same location as before)
    • workspace, %workspace%/.bazelrc (unless --noworkspace_rc)
    • user, $HOME/.bazelrc (unless --nohome_rc)
    • command-line provided, passed as --bazelrc or nothing if the flag is absent.

    This means that the following rc's will be ignored from now on:

    • %workspace%/tools/bazel.rc
    • %binary_dir%/bazel.bazelrc

    The intent is to simplify the list of rc files, and remove the "master" vs "user" grouping that had been confusing. The home and workspace rc are no longer dependent on the --bazelrc flag being present, there are no longer 2 workspace rcs (one gated by --nomaster_bazelrc and one by the presence of an explicit --bazelrc). The binary location was useless to most people, and was legacy from the way that Google's repo is set up, so is excised outright,

  3. cvcal commented on Aug 3, 2018

    @cvcal
    Contributor

    This is a breaking change, there's no good way to avoid it, unfortunately.

    • Why can't we maintain both versions during a deprecation period, allow people to opt-in?
      • We can't gate this by startup option. This change affects startup options, including which startup options are accepted (--home_rc, etc) so layering another startup option on top of this is bad.
      • We avoid gating things on environment variable - most users lose track of which envvars are set, so this becomes a maintainability problem
      • Bazel's client code, in c++, is maintained with a ten-foot stick on this team. We're all much more familiar with the server, so adding complications to the client, to support the dual behavior by some gating method, is undesirable.
      • And finally, ending any sort of deprecation period is itself a breaking change - the pain is only postponed. I realize it's nice to control when the tide-over point will be, but with the other concerns, I think it isn't worth it.

    Instead, this avoids the duality, but has a very easy workaround, which allows simultaneous support of 2 bazel versions. A warning will let you know if any old rc files are not being read, and you can import them to avoid the confusion:

    • In your workspace/.bazelrc, add the line import %workspace%/tools/bazel.rc
    • Similarly, in your system or home rc, whichever is appropriate depending on where you keep the bazel binary, import the %binary_dir%/bazel.bazelrc file.

    You can also do this in reverse, migrate the contents of the old files, and have them simply "import" the new ones as needed, but this is a bit more brittle, since you might double-import some files, what with the weird legacy userc behavior. Also, in this order, the warning will continue to be printed, since the old rc files still exist, even if they just contain an import statement - this isn't bad, but log spam annoys certain people.

    This way, old Bazels will load the old files, and new ones will get the same flags through the new locations. You can stop doing this once you stop supporting versions of Bazel that expect the old locations.

    Note that the flag --[no]master_bazelrc is still accepted - it will be taken into account when creating the warning telling you which old files would have been loaded, but does NOT affect the new files in anyway.

  4. cvcal commented on Aug 3, 2018

    @cvcal
    Contributor

    A final piece of advice: If you want additional insight into what Bazel is doing, where it's looking for files, and which files it has found, use the client option --client_debug (bazel --client_debug build): it will give you the full list of potential files (on the log line "Looking for the following rc files:") that it's looking for, and, for each file that it finds and parses, it will also log that.

    Another useful option to help debug this sort of thing is --announce_rc, (this is a server option, so it goes after the command, bazel build --announce_rc), and will list all options that are loaded from rc files, along with where they came from. These are output in order that they are parsed by Bazel, which helps find conflicts.

  5. davido commented on Aug 3, 2018

    @davido
    Contributor
  6. added a commit that references this issue on Aug 3, 2018
  7. 6 remaining items

  8. davido commented on Aug 8, 2018

    @davido
    Contributor

    Mentioned gerrit CL was merged, but only on stable-2.14 branch. We still need to merge that change up to master.

  9. added a commit that references this issue on Aug 10, 2018
  10. added
    P2
    P3
    and removed
    P1
    P2
    on Sep 15, 2018
  11. amlinux commented on Nov 20, 2018

    @amlinux

    I was hit by WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files error message, and it was quite unhelpful. I spent a lot of time trying to find where the standard rc files were supposed to be.

    Could you please update the message to something referencing the list of standard paths or at least with a link to the doc?

  12. meisterT commented on May 12, 2020

    @meisterT
    Member

    I assume this is no longer relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions