BEGIN_PUBLIC
    remove --master_bazelrc from our codebase + update documentation.
END_PUBLIC

PiperOrigin-RevId: 434466313
diff --git a/scripts/bootstrap/buildenv.sh b/scripts/bootstrap/buildenv.sh
index f004805..a5690402 100755
--- a/scripts/bootstrap/buildenv.sh
+++ b/scripts/bootstrap/buildenv.sh
@@ -313,7 +313,7 @@
 
 # Return the target that a bind point to, using Bazel query.
 function get_bind_target() {
-  $BAZEL --bazelrc=${BAZELRC} --nomaster_bazelrc ${BAZEL_DIR_STARTUP_OPTIONS} \
+  $BAZEL --bazelrc=${BAZELRC} ${BAZEL_DIR_STARTUP_OPTIONS} \
     query "deps($1, 1) - $1"
 }
 
diff --git a/site/en/docs/bazelrc.md b/site/en/docs/bazelrc.md
index de19a99..7943da72 100644
--- a/site/en/docs/bazelrc.md
+++ b/site/en/docs/bazelrc.md
@@ -229,9 +229,9 @@
 
 ### The global bazelrc file {:#global-bazelrc}
 
-In addition to your personal `.bazelrc` file, Bazel reads global bazelrc
-files in this order: `$workspace/tools/bazel.rc`, `.bazelrc` next to the
-Bazel binary, and `/etc/bazel.bazelrc`. (It's fine if any are missing.)
+Bazel reads optional bazelrc files in this order:
+- System rc-file located at `etc/bazel.bazelrc`.
+- Workspace rc-file located at `$workspace/tools/bazel.rc`.
+- Home rc-file localted at `$HOME/.bazelrc`
 
-You can make Bazel ignore the global bazelrcs by passing the
-`--nomaster_bazelrc` startup option.
+Each bazelrc file listed here has a corresponding flag which can be used to disable them (e.g. `--nosystem_rc`, `--noworkspace_rc`, `--nohome_rc`). You can also make Bazel ignore all bazelrcs by passing the `--ignore_all_rc_files` startup option.
diff --git a/src/main/cpp/bazel_startup_options.cc b/src/main/cpp/bazel_startup_options.cc
index 3d702e3..1de82ed 100644
--- a/src/main/cpp/bazel_startup_options.cc
+++ b/src/main/cpp/bazel_startup_options.cc
@@ -27,11 +27,8 @@
       user_bazelrc_(""),
       use_system_rc(true),
       use_workspace_rc(true),
-      use_home_rc(true),
-      use_master_bazelrc_(true) {
+      use_home_rc(true) {
   RegisterNullaryStartupFlagNoRc("home_rc", &use_home_rc);
-  RegisterNullaryStartupFlagNoRc("master_bazelrc", &use_master_bazelrc_);
-  OverrideOptionSourcesKey("master_bazelrc", "blazerc");
   RegisterNullaryStartupFlagNoRc("system_rc", &use_system_rc);
   RegisterNullaryStartupFlagNoRc("workspace_rc", &use_workspace_rc);
   RegisterUnaryStartupFlag("bazelrc");
diff --git a/src/main/cpp/bazel_startup_options.h b/src/main/cpp/bazel_startup_options.h
index 14d4132..1bbc746 100644
--- a/src/main/cpp/bazel_startup_options.h
+++ b/src/main/cpp/bazel_startup_options.h
@@ -42,8 +42,6 @@
   bool use_system_rc;
   bool use_workspace_rc;
   bool use_home_rc;
-  // TODO(b/36168162): Remove the master rc flag.
-  bool use_master_bazelrc_;
 };
 
 }  // namespace blaze
diff --git a/src/main/cpp/startup_options.h b/src/main/cpp/startup_options.h
index d6c8d02..208e4bc 100644
--- a/src/main/cpp/startup_options.h
+++ b/src/main/cpp/startup_options.h
@@ -386,20 +386,20 @@
   // lazily). Not guarded by a mutex - StartupOptions is not thread-safe.
   mutable std::pair<blaze_util::Path, JavabaseType> default_server_javabase_;
 
-  // Startup flags that don't expect a value, e.g. "master_bazelrc".
-  // Valid uses are "--master_bazelrc" are "--nomaster_bazelrc".
-  // Keys are positive and negative flag names (e.g. "--master_bazelrc" and
-  // "--nomaster_bazelrc"), values are pointers to the boolean to mutate.
+  // Startup flags that don't expect a value, e.g. "home_rc".
+  // Valid uses are "--home_rc" are "--nohome_rc".
+  // Keys are positive and negative flag names (e.g. "--home_rc" and
+  // "--nohome_rc"), values are pointers to the boolean to mutate.
   std::unordered_map<std::string, bool *> all_nullary_startup_flags_;
 
   // Subset of 'all_nullary_startup_flags_'.
-  // Contains positive and negative names (e.g. "--master_bazelrc" and
-  // "--nomaster_bazelrc") of flags that must not appear in .bazelrc files.
+  // Contains positive and negative names (e.g. "--home_rc" and
+  // "--nohome_rc") of flags that must not appear in .bazelrc files.
   std::unordered_set<std::string> no_rc_nullary_startup_flags_;
 
   // Subset of 'all_nullary_startup_flags_'.
-  // Contains positive and negative names (e.g. "--master_bazelrc" and
-  // "--nomaster_bazelrc") of flags that have a special handler.
+  // Contains positive and negative names (e.g. "--home_rc" and
+  // "--nohome_rc") of flags that have a special handler.
   // Can be used for tri-state flags where omitting the flag completely means
   // leaving the tri-state as "auto".
   std::unordered_map<std::string, SpecialNullaryFlagHandler>
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/BazelStartupOptionsModule.java b/src/main/java/com/google/devtools/build/lib/bazel/BazelStartupOptionsModule.java
index b87146f..eddd519 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/BazelStartupOptionsModule.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/BazelStartupOptionsModule.java
@@ -18,7 +18,6 @@
 import com.google.devtools.common.options.Option;
 import com.google.devtools.common.options.OptionDocumentationCategory;
 import com.google.devtools.common.options.OptionEffectTag;
-import com.google.devtools.common.options.OptionMetadataTag;
 import com.google.devtools.common.options.OptionsBase;
 
 /** Provides Bazel startup flags. */
@@ -48,21 +47,6 @@
                 + "Note: command line options will always supersede any option in bazelrc.")
     public String blazerc;
 
-    // TODO(b/36168162): Remove this after the transition period is ower. This now only serves to
-    // provide accurate warnings about which old files are being missed.
-    @Option(
-        name = "master_bazelrc",
-        defaultValue = "true", // NOTE: purely decorative, rc files are read by the client.
-        documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
-        effectTags = {OptionEffectTag.NO_OP},
-        metadataTags = {OptionMetadataTag.DEPRECATED},
-        help =
-            "If this option is false, the master bazelrcs are not read. Otherwise, Bazel looks for "
-                + "master rcs in three locations, reading them all, in order: "
-                + "$workspace/tools/bazel.rc, a .bazelrc file near the bazel binary, and the "
-                + "global rc, /etc/bazel.bazelrc.")
-    public boolean masterBlazerc;
-
     // For the system_rc, it can be /etc/bazel.bazelrc, or a special Windows value, or can be
     // custom-set by the Bazel distributor. We don't list a known path in the help output in order
     // to avoid misdocumentation here.
diff --git a/src/test/cpp/bazel_startup_options_test.cc b/src/test/cpp/bazel_startup_options_test.cc
index 894c810..33ae9c2 100644
--- a/src/test/cpp/bazel_startup_options_test.cc
+++ b/src/test/cpp/bazel_startup_options_test.cc
@@ -102,7 +102,6 @@
   ExpectValidNullaryOption(options, "host_jvm_debug");
   ExpectValidNullaryOption(options, "autodetect_server_javabase");
   ExpectValidNullaryOption(options, "ignore_all_rc_files");
-  ExpectValidNullaryOption(options, "master_bazelrc");
   ExpectValidNullaryOption(options, "shutdown_on_low_sys_mem");
   ExpectValidNullaryOption(options, "system_rc");
   ExpectValidNullaryOption(options, "watchfs");
@@ -190,7 +189,7 @@
   // Warning for nomaster would feel pretty spammy - it's redundant, but the
   // behavior is as one would expect, so warning is unnecessary.
   ParseStartupOptionsAndExpectWarning(
-      startup_options_.get(), {"--ignore_all_rc_files", "--nomaster_bazelrc"},
+      startup_options_.get(), {"--ignore_all_rc_files"},
       "");
 }
 
@@ -207,7 +206,7 @@
 TEST_F(BazelStartupOptionsTest, FinalValueOfIgnoreIsUsedForWarning) {
   ParseStartupOptionsAndExpectWarning(
       startup_options_.get(),
-      {"--ignore_all_rc_files", "--master_bazelrc", "--noignore_all_rc_files"},
+      {"--ignore_all_rc_files", "--noignore_all_rc_files"},
       "");
 }
 
diff --git a/src/test/cpp/option_processor_test.cc b/src/test/cpp/option_processor_test.cc
index 504ea1c..b833c7e 100644
--- a/src/test/cpp/option_processor_test.cc
+++ b/src/test/cpp/option_processor_test.cc
@@ -240,9 +240,9 @@
 
 TEST_F(OptionProcessorTest, SplitCommandLineWithAllParams) {
   SuccessfulSplitStartupOptionsTest(
-      {"bazel", "--nomaster_bazelrc", "build", "--bar", ":mytarget"},
+      {"bazel", "--ignore_all_rc_files", "build", "--bar", ":mytarget"},
       CommandLine("bazel",
-                  {"--nomaster_bazelrc"},
+                  {"--ignore_all_rc_files"},
                   "build",
                   {"--bar", ":mytarget"}));
 }
@@ -276,9 +276,10 @@
 
 TEST_F(OptionProcessorTest, SplitCommandLineWithMultipleStartup) {
   SuccessfulSplitStartupOptionsTest(
-      {"bazel", "--bazelrc", "foo", "--nomaster_bazelrc", "build", ":mytarget"},
+      {"bazel", "--bazelrc", "foo", "--ignore_all_rc_files", "build",
+       ":mytarget"},
       CommandLine("bazel",
-                  {"--bazelrc=foo", "--nomaster_bazelrc"},
+                  {"--bazelrc=foo", "--ignore_all_rc_files"},
                   "build",
                   {":mytarget"}));
 }
@@ -335,9 +336,9 @@
 
 TEST_F(OptionProcessorTest, SplitCommandLineWithDashDash) {
   SuccessfulSplitStartupOptionsTest(
-      {"bazel", "--nomaster_bazelrc", "build", "--b", "--", ":mytarget"},
+      {"bazel", "--ignore_all_rc_files", "build", "--b", "--", ":mytarget"},
       CommandLine("bazel",
-                  {"--nomaster_bazelrc"},
+                  {"--ignore_all_rc_files"},
                   "build",
                   {"--b", "--", ":mytarget"}));
 }
@@ -403,6 +404,15 @@
   std::vector<std::string> expected = {foo_path};
   ASSERT_EQ(expected, internal::DedupeBlazercPaths(input));
 }
+
+
+TEST_F(OptionProcessorTest,
+       SplitCommandLineFailsWithDeprecatedOptionInStartupArgs) {
+  FailedSplitStartupOptionsTest(
+      {"bazel", "--nomaster_bazelrc"},
+      "Unknown startup option: '--nomaster_bazelrc'.\n"
+          "  For more info, run 'bazel help startup_options'.");
+}
 #endif  // !defined(_WIN32) && !defined(__CYGWIN__)
 
 }  // namespace blaze
diff --git a/src/test/cpp/rc_file_test.cc b/src/test/cpp/rc_file_test.cc
index b3a6fda..ee8880b 100644
--- a/src/test/cpp/rc_file_test.cc
+++ b/src/test/cpp/rc_file_test.cc
@@ -311,37 +311,6 @@
   EXPECT_THAT(output, HasSubstr(binary_rc));
 }
 
-TEST_F(
-    GetRcFileTest,
-    GetRcFilesDoesNotWarnAboutIgnoredMasterRcFilesWhenNoMasterBazelrcIsPassed) {
-  std::string workspace_rc;
-  ASSERT_TRUE(SetUpLegacyMasterRcFileInWorkspace("", &workspace_rc));
-  std::string binary_rc;
-  ASSERT_TRUE(SetUpLegacyMasterRcFileAlongsideBinary("", &binary_rc));
-
-  const CommandLine cmd_line =
-      CommandLine(binary_path_, {"--nomaster_bazelrc"}, "build", {});
-  std::string error = "check that this string is not modified";
-  std::vector<std::unique_ptr<RcFile>> parsed_rcs;
-
-  testing::internal::CaptureStderr();
-  const blaze_exit_code::ExitCode exit_code =
-      option_processor_->GetRcFiles(workspace_layout_.get(), workspace_, cwd_,
-                                    &cmd_line, &parsed_rcs, &error);
-  const std::string output = testing::internal::GetCapturedStderr();
-
-  EXPECT_EQ(blaze_exit_code::SUCCESS, exit_code);
-  EXPECT_EQ("check that this string is not modified", error);
-
-  // Expect that nothing is logged to stderr about ignored rc files when these
-  // files are disabled.
-  EXPECT_THAT(
-      output,
-      Not(HasSubstr("The following rc files are no longer being read")));
-  EXPECT_THAT(output, Not(HasSubstr(workspace_rc)));
-  EXPECT_THAT(output, Not(HasSubstr(binary_rc)));
-}
-
 TEST_F(GetRcFileTest, GetRcFilesReadsCommandLineRc) {
   const std::string cmdline_rc_path =
       blaze_util::JoinPath(workspace_, "mybazelrc");
@@ -350,7 +319,7 @@
   ASSERT_TRUE(blaze_util::WriteFile("", cmdline_rc_path, 0755));
 
   const CommandLine cmd_line = CommandLine(
-      binary_path_, {"--nomaster_bazelrc", "--bazelrc=" + cmdline_rc_path},
+      binary_path_, {"--bazelrc=" + cmdline_rc_path},
       "build", {});
   std::string error = "check that this string is not modified";
   std::vector<std::unique_ptr<RcFile>> parsed_rcs;
@@ -502,7 +471,7 @@
       blaze_util::MakeDirectories(blaze_util::Dirname(cmdline_rc_path), 0755));
   ASSERT_TRUE(blaze_util::WriteFile("startup --foo", cmdline_rc_path, 0755));
 
-  const std::vector<std::string> args = {binary_path_, "--nomaster_bazelrc",
+  const std::vector<std::string> args = {binary_path_,
                                          "--bazelrc=" + cmdline_rc_path,
                                          "build"};
   const std::string expected_error =
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/CommandLineEventTest.java b/src/test/java/com/google/devtools/build/lib/runtime/CommandLineEventTest.java
index 29707b2..9f67cc1 100644
--- a/src/test/java/com/google/devtools/build/lib/runtime/CommandLineEventTest.java
+++ b/src/test/java/com/google/devtools/build/lib/runtime/CommandLineEventTest.java
@@ -108,8 +108,7 @@
         OptionsParser.builder()
             .optionsClasses(BlazeServerStartupOptions.class, Options.class)
             .build();
-    fakeStartupOptions.parse(
-        "--bazelrc=/some/path", "--master_bazelrc", "--bazelrc", "/some/other/path");
+    fakeStartupOptions.parse("--bazelrc=/some/path", "--bazelrc", "/some/other/path");
     OptionsParser fakeCommandOptions =
         OptionsParser.builder().optionsClasses(TestOptions.class).build();
 
@@ -128,12 +127,10 @@
 
     // Expect the provided rc-related startup options are correctly listed
     assertThat(line.getSections(0).getChunkList().getChunk(0)).isEqualTo("testblaze");
-    assertThat(line.getSections(1).getOptionList().getOptionCount()).isEqualTo(3);
+    assertThat(line.getSections(1).getOptionList().getOptionCount()).isEqualTo(2);
     assertThat(line.getSections(1).getOptionList().getOption(0).getCombinedForm())
         .isEqualTo("--bazelrc=/some/path");
     assertThat(line.getSections(1).getOptionList().getOption(1).getCombinedForm())
-        .isEqualTo("--master_bazelrc");
-    assertThat(line.getSections(1).getOptionList().getOption(2).getCombinedForm())
         .isEqualTo("--bazelrc /some/other/path");
     assertThat(line.getSections(2).getChunkList().getChunk(0)).isEqualTo("someCommandName");
     assertThat(line.getSections(3).getOptionList().getOptionCount()).isEqualTo(0);
@@ -189,8 +186,7 @@
         OptionsParser.builder()
             .optionsClasses(BlazeServerStartupOptions.class, Options.class)
             .build();
-    fakeStartupOptions.parse(
-        "--bazelrc=/some/path", "--master_bazelrc", "--bazelrc", "/some/other/path");
+    fakeStartupOptions.parse("--bazelrc=/some/path", "--bazelrc", "/some/other/path");
     OptionsParser fakeCommandOptions =
         OptionsParser.builder().optionsClasses(TestOptions.class).build();
 
diff --git a/src/test/py/bazel/test_base.py b/src/test/py/bazel/test_base.py
index 1df8a3a..af621af 100644
--- a/src/test/py/bazel/test_base.py
+++ b/src/test/py/bazel/test_base.py
@@ -351,8 +351,7 @@
     """
     return self.RunProgram([
         self.Rlocation('io_bazel/src/bazel'),
-        '--bazelrc=' + self._test_bazelrc,
-        '--nomaster_bazelrc',
+        '--bazelrc=' + self._test_bazelrc
     ] + args, env_remove, env_add, False, cwd, allow_failure)
 
   def StartRemoteWorker(self):
diff --git a/src/test/shell/bazel/bazel_test_test.sh b/src/test/shell/bazel/bazel_test_test.sh
index 87f3bbb..51b1a87 100755
--- a/src/test/shell/bazel/bazel_test_test.sh
+++ b/src/test/shell/bazel/bazel_test_test.sh
@@ -222,7 +222,7 @@
   expect_log '1 test passes.$'
 }
 
-# This test uses "--nomaster_bazelrc" since outside .bazelrc files can pollute
+# This test uses "--ignore_all_rc_files" since outside .bazelrc files can pollute
 # this environment. Just "--bazelrc=/dev/null" is not sufficient to fix.
 function test_run_under_path() {
   mkdir -p testing || fail "mkdir testing failed"
@@ -241,7 +241,7 @@
   chmod u+x scripts/hello
 
   # We don't just use the local PATH, but use the test's PATH, which is more restrictive.
-  PATH=$PATH:$PWD/scripts bazel --nomaster_bazelrc test //testing:t1 -s --run_under=hello \
+  PATH=$PATH:$PWD/scripts bazel --ignore_all_rc_files test //testing:t1 -s --run_under=hello \
     --test_output=all --incompatible_strict_action_env=true >& $TEST_log && fail "Expected failure"
 
   # With --action_env=PATH, the local PATH is forwarded to the test.
@@ -626,7 +626,7 @@
   expect_log 'FAILED.*com\.example\.myproject\.Fail\.testFail'
 }
 
-# This test uses "--nomaster_bazelrc" since outside .bazelrc files can pollute
+# This test uses "--ignore_all_rc_files" since outside .bazelrc files can pollute
 # this environment. Just "--bazelrc=/dev/null" is not sufficient to fix.
 function test_flaky_test() {
   cat >BUILD <<EOF
@@ -658,7 +658,7 @@
   chmod +x true.sh flaky.sh false.sh
 
   # We do not use sandboxing so we can trick to be deterministically flaky
-  bazel --nomaster_bazelrc test --experimental_ui_debug_all_events \
+  bazel --ignore_all_rc_files test --experimental_ui_debug_all_events \
       --spawn_strategy=standalone //:flaky &> $TEST_log \
       || fail "//:flaky should have passed with flaky support"
   [ -f "${FLAKE_FILE}" ] || fail "Flaky test should have created the flake-file!"
@@ -672,7 +672,7 @@
   cat bazel-testlogs/flaky/test.log &> $TEST_log
   assert_equals "pass" "$(awk "NR == $(wc -l < $TEST_log)" $TEST_log)"
 
-  bazel --nomaster_bazelrc test --experimental_ui_debug_all_events //:pass \
+  bazel --ignore_all_rc_files test --experimental_ui_debug_all_events //:pass \
       &> $TEST_log || fail "//:pass should have passed"
   expect_log_once "PASS.*: //:pass"
   expect_log_once "PASSED"
@@ -681,7 +681,7 @@
   cat bazel-testlogs/flaky/test.log &> $TEST_log
   assert_equals "pass" "$(tail -1 bazel-testlogs/flaky/test.log)"
 
-  bazel --nomaster_bazelrc test --experimental_ui_debug_all_events //:fail \
+  bazel --ignore_all_rc_files test --experimental_ui_debug_all_events //:fail \
       &> $TEST_log && fail "//:fail should have failed" \
       || true
   expect_log_n "FAIL.*: //:fail (.*/fail/test_attempts/attempt_..log)" 2