Rename PackageCacheOptions to PackageCache.

PackageCache refers to a historical implementation of Bazel, predating
Skyframe. Rename the options and fix names referring to the PackageCache.

RELNOTES: None.
PiperOrigin-RevId: 306265392
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/BazelRepositoryModule.java b/src/main/java/com/google/devtools/build/lib/bazel/BazelRepositoryModule.java
index 70e950b..ee0022a 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/BazelRepositoryModule.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/BazelRepositoryModule.java
@@ -44,7 +44,7 @@
 import com.google.devtools.build.lib.bazel.rules.android.AndroidSdkRepositoryRule;
 import com.google.devtools.build.lib.cmdline.RepositoryName;
 import com.google.devtools.build.lib.events.Event;
-import com.google.devtools.build.lib.pkgcache.PackageCacheOptions;
+import com.google.devtools.build.lib.pkgcache.PackageOptions;
 import com.google.devtools.build.lib.rules.repository.LocalRepositoryFunction;
 import com.google.devtools.build.lib.rules.repository.LocalRepositoryRule;
 import com.google.devtools.build.lib.rules.repository.ManagedDirectoriesKnowledgeImpl;
@@ -223,7 +223,7 @@
   @Override
   public void beforeCommand(CommandEnvironment env) {
     clientEnvironmentSupplier.set(env.getRepoEnv());
-    PackageCacheOptions pkgOptions = env.getOptions().getOptions(PackageCacheOptions.class);
+    PackageOptions pkgOptions = env.getOptions().getOptions(PackageOptions.class);
     isFetch.set(pkgOptions != null && pkgOptions.fetch);
     resolvedFile = Optional.<RootedPath>absent();
     resolvedFileReplacingWorkspace = Optional.<RootedPath>absent();
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/commands/FetchCommand.java b/src/main/java/com/google/devtools/build/lib/bazel/commands/FetchCommand.java
index 5d18bc2..5f693b7 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/commands/FetchCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/commands/FetchCommand.java
@@ -20,7 +20,7 @@
 import com.google.devtools.build.lib.analysis.NoBuildRequestFinishedEvent;
 import com.google.devtools.build.lib.events.Event;
 import com.google.devtools.build.lib.packages.Target;
-import com.google.devtools.build.lib.pkgcache.PackageCacheOptions;
+import com.google.devtools.build.lib.pkgcache.PackageOptions;
 import com.google.devtools.build.lib.query2.common.AbstractBlazeQueryEnvironment;
 import com.google.devtools.build.lib.query2.engine.QueryEnvironment.Setting;
 import com.google.devtools.build.lib.query2.engine.QueryEvalResult;
@@ -43,7 +43,7 @@
 /** Fetches external repositories. Which is so fetch. */
 @Command(
     name = FetchCommand.NAME,
-    options = {PackageCacheOptions.class, KeepGoingOption.class, LoadingPhaseThreadsOption.class},
+    options = {PackageOptions.class, KeepGoingOption.class, LoadingPhaseThreadsOption.class},
     help = "resource:fetch.txt",
     shortDescription = "Fetches external repositories that are prerequisites to the targets.",
     allowResidue = true,
@@ -65,7 +65,7 @@
     }
 
     try {
-      env.setupPackageCache(options);
+      env.syncPackageLoading(options);
     } catch (InterruptedException e) {
       env.getReporter().handle(Event.error("fetch interrupted"));
       return BlazeCommandResult.exitCode(ExitCode.INTERRUPTED);
@@ -74,7 +74,7 @@
       return BlazeCommandResult.exitCode(e.getExitCode());
     }
 
-    PackageCacheOptions pkgOptions = options.getOptions(PackageCacheOptions.class);
+    PackageOptions pkgOptions = options.getOptions(PackageOptions.class);
     if (!pkgOptions.fetch) {
       env.getReporter().handle(Event.error(null, "You cannot run fetch with --fetch=false"));
       return BlazeCommandResult.exitCode(ExitCode.COMMAND_LINE_ERROR);
diff --git a/src/main/java/com/google/devtools/build/lib/bazel/commands/SyncCommand.java b/src/main/java/com/google/devtools/build/lib/bazel/commands/SyncCommand.java
index 183a624..7b7dc23 100644
--- a/src/main/java/com/google/devtools/build/lib/bazel/commands/SyncCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/bazel/commands/SyncCommand.java
@@ -28,7 +28,7 @@
 import com.google.devtools.build.lib.events.ExtendedEventHandler.ResolvedEvent;
 import com.google.devtools.build.lib.packages.Rule;
 import com.google.devtools.build.lib.packages.WorkspaceFileValue;
-import com.google.devtools.build.lib.pkgcache.PackageCacheOptions;
+import com.google.devtools.build.lib.pkgcache.PackageOptions;
 import com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction;
 import com.google.devtools.build.lib.rules.repository.RepositoryDirectoryValue;
 import com.google.devtools.build.lib.rules.repository.ResolvedHashesFunction;
@@ -59,7 +59,7 @@
 @Command(
     name = SyncCommand.NAME,
     options = {
-      PackageCacheOptions.class,
+      PackageOptions.class,
       KeepGoingOption.class,
       LoadingPhaseThreadsOption.class,
       SyncOptions.class
@@ -94,7 +94,7 @@
                   true,
                   true,
                   env.getCommandId().toString()));
-      env.setupPackageCache(options);
+      env.syncPackageLoading(options);
       SkyframeExecutor skyframeExecutor = env.getSkyframeExecutor();
 
       SyncOptions syncOptions = options.getOptions(SyncOptions.class);
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java b/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java
index 576d840..f2be94e 100644
--- a/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java
+++ b/src/main/java/com/google/devtools/build/lib/buildtool/BuildRequest.java
@@ -28,7 +28,7 @@
 import com.google.devtools.build.lib.exec.ExecutionOptions;
 import com.google.devtools.build.lib.packages.StarlarkSemanticsOptions;
 import com.google.devtools.build.lib.pkgcache.LoadingOptions;
-import com.google.devtools.build.lib.pkgcache.PackageCacheOptions;
+import com.google.devtools.build.lib.pkgcache.PackageOptions;
 import com.google.devtools.build.lib.runtime.KeepGoingOption;
 import com.google.devtools.build.lib.runtime.LoadingPhaseThreadsOption;
 import com.google.devtools.build.lib.runtime.UiOptions;
@@ -75,7 +75,7 @@
   private static final ImmutableList<Class<? extends OptionsBase>> MANDATORY_OPTIONS =
       ImmutableList.of(
           BuildRequestOptions.class,
-          PackageCacheOptions.class,
+          PackageOptions.class,
           StarlarkSemanticsOptions.class,
           LoadingOptions.class,
           AnalysisOptions.class,
@@ -201,11 +201,9 @@
     return getOptions(BuildRequestOptions.class);
   }
 
-  /**
-   * Returns the set of options related to the loading phase.
-   */
-  public PackageCacheOptions getPackageCacheOptions() {
-    return getOptions(PackageCacheOptions.class);
+  /** Returns the set of options related to the loading phase. */
+  public PackageOptions getPackageOptions() {
+    return getOptions(PackageOptions.class);
   }
 
   /**
diff --git a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
index a44ec24..af600c3 100644
--- a/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
+++ b/src/main/java/com/google/devtools/build/lib/buildtool/ExecutionTool.java
@@ -731,7 +731,7 @@
                 .setVerboseExplanations(options.verboseExplanations)
                 .build()),
         env.getTopDownActionCache(),
-        request.getPackageCacheOptions().checkOutputFiles
+        request.getPackageOptions().checkOutputFiles
             ? modifiedOutputFiles
             : ModifiedFileSet.NOTHING_MODIFIED,
         env.getFileCache(),
diff --git a/src/main/java/com/google/devtools/build/lib/packages/GlobCache.java b/src/main/java/com/google/devtools/build/lib/packages/GlobCache.java
index 1d83a50..cb2d512 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/GlobCache.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/GlobCache.java
@@ -92,7 +92,8 @@
    * @param globExecutor thread pool for glob evaluation.
    * @param maxDirectoriesToEagerlyVisit the number of directories to eagerly traverse on the first
    *     glob for a given package, in order to warm the filesystem. -1 means do no eager traversal.
-   *     See {@code PackageCacheOptions#maxDirectoriesToEagerlyVisitInGlobbing}.
+   *     See {@link
+   *     com.google.devtools.build.lib.pkgcache.PackageOptions#maxDirectoriesToEagerlyVisitInGlobbing}.
    */
   public GlobCache(
       final Path packageDirectory,
diff --git a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java
index 2181705..2c8cb30 100644
--- a/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java
+++ b/src/main/java/com/google/devtools/build/lib/packages/PackageFactory.java
@@ -206,10 +206,10 @@
 
   /**
    * Sets the number of directories to eagerly traverse on the first glob for a given package, in
-   * order to warm the filesystem. -1 means do no eager traversal. See {@code
-   * PackageCacheOptions#maxDirectoriesToEagerlyVisitInGlobbing}. -2 means do the eager traversal
-   * using the regular globbing infrastructure, i.e. sharing the globbing threads and caching the
-   * actual glob results.
+   * order to warm the filesystem. -1 means do no eager traversal. See {@link
+   * com.google.devtools.build.lib.pkgcache.PackageOptions#maxDirectoriesToEagerlyVisitInGlobbing}.
+   * -2 means do the eager traversal using the regular globbing infrastructure, i.e. sharing the
+   * globbing threads and caching the actual glob results.
    */
   public void setMaxDirectoriesToEagerlyVisitInGlobbing(
       int maxDirectoriesToEagerlyVisitInGlobbing) {
diff --git a/src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java b/src/main/java/com/google/devtools/build/lib/pkgcache/PackageOptions.java
similarity index 98%
rename from src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java
rename to src/main/java/com/google/devtools/build/lib/pkgcache/PackageOptions.java
index 2f86dc0..a233964 100644
--- a/src/main/java/com/google/devtools/build/lib/pkgcache/PackageCacheOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/pkgcache/PackageOptions.java
@@ -34,10 +34,8 @@
 import com.google.devtools.common.options.OptionsParsingException;
 import java.util.List;
 
-/**
- * Options for configuring the PackageCache.
- */
-public class PackageCacheOptions extends OptionsBase {
+/** Options for configuring Packages -- loading and default behaviors. */
+public class PackageOptions extends OptionsBase {
 
   /**
    * Converter for the {@code --default_visibility} option.
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
index fa214bb..d76e9fa 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/BlazeCommandDispatcher.java
@@ -506,7 +506,7 @@
           && !commandAnnotation.name().equals("clean")
           && !commandAnnotation.name().equals("info")) {
         try {
-          env.setupPackageCache(options);
+          env.syncPackageLoading(options);
         } catch (InterruptedException e) {
           Thread.currentThread().interrupt();
           reporter.handle(Event.error("command interrupted while setting up package cache"));
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
index 373cac6..a3a9519 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/CommandEnvironment.java
@@ -27,8 +27,8 @@
 import com.google.devtools.build.lib.events.Reporter;
 import com.google.devtools.build.lib.exec.SingleBuildFileCache;
 import com.google.devtools.build.lib.packages.StarlarkSemanticsOptions;
-import com.google.devtools.build.lib.pkgcache.PackageCacheOptions;
 import com.google.devtools.build.lib.pkgcache.PackageManager;
+import com.google.devtools.build.lib.pkgcache.PackageOptions;
 import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
 import com.google.devtools.build.lib.profiler.Profiler;
 import com.google.devtools.build.lib.profiler.ProfilerTask;
@@ -98,7 +98,7 @@
   private TopDownActionCache topDownActionCache;
   private Path workingDirectory;
   private String workspaceName;
-  private boolean haveSetupPackageCache = false;
+  private boolean hasSyncedPackageLoading = false;
 
   // This AtomicReference is set to:
   //   - null, if neither BlazeModuleEnvironment#exit nor #precompleteCommand have been called
@@ -166,7 +166,7 @@
     timestampGranularityMonitor.setCommandStartTime();
 
     // TODO(ulfjack): We don't call beforeCommand() in tests, but rely on workingDirectory being set
-    // in setupPackageCache(). This leads to NPE if we don't set it here.
+    // in syncPackageLoading(). This leads to NPE if we don't set it here.
     Path workspacePath = directories.getWorkspace();
     this.setWorkingDirectory(workspacePath);
     this.workspaceName = null;
@@ -178,9 +178,7 @@
           workspace
               .getSkyframeExecutor()
               .createPackageLocator(
-                  reporter,
-                  options.getOptions(PackageCacheOptions.class).packagePath,
-                  workingDirectory);
+                  reporter, options.getOptions(PackageOptions.class).packagePath, workingDirectory);
     } else {
       this.packageLocator = null;
     }
@@ -241,7 +239,7 @@
       return false;
     }
     for (int i = 0; i < command.options().length; ++i) {
-      if (command.options()[i] == PackageCacheOptions.class) {
+      if (command.options()[i] == PackageOptions.class) {
         return true;
       }
     }
@@ -592,25 +590,23 @@
   }
 
   /**
-   * Initializes the package cache using the given options, and syncs the package cache. Also
-   * injects the Starlark semantics using the options for the {@link
-   * com.google.devtools.build.lib.analysis.config.BuildConfiguration}.
+   * Initializes and syncs the graph with the given options, readying it for the next evaluation.
    */
-  public void setupPackageCache(OptionsProvider options)
+  public void syncPackageLoading(OptionsProvider options)
       throws InterruptedException, AbruptExitException {
-    // We want to ensure that we're never calling #setupPackageCache twice in the same build because
-    // it does the very expensive work of diffing the cache between incremental builds.
+    // We want to ensure that we're never calling #syncPackageLoading twice in the same build
+    // because it does the very expensive work of diffing the cache between incremental builds.
     // {@link SequencedSkyframeExecutor#handleDiffs} is the particular method we don't want to be
     // calling twice. We could feasibly factor it out of this call.
-    if (this.haveSetupPackageCache) {
+    if (hasSyncedPackageLoading) {
       throw new IllegalStateException(
           "We should never call this method more than once over the course of a single command");
     }
-    this.haveSetupPackageCache = true;
+    hasSyncedPackageLoading = true;
     getSkyframeExecutor()
         .sync(
             reporter,
-            options.getOptions(PackageCacheOptions.class),
+            options.getOptions(PackageOptions.class),
             packageLocator,
             options.getOptions(StarlarkSemanticsOptions.class),
             getCommandId(),
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java
index eef3eee..3b13d69 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/BuildCommand.java
@@ -22,7 +22,7 @@
 import com.google.devtools.build.lib.exec.ExecutionOptions;
 import com.google.devtools.build.lib.exec.local.LocalExecutionOptions;
 import com.google.devtools.build.lib.pkgcache.LoadingOptions;
-import com.google.devtools.build.lib.pkgcache.PackageCacheOptions;
+import com.google.devtools.build.lib.pkgcache.PackageOptions;
 import com.google.devtools.build.lib.profiler.Profiler;
 import com.google.devtools.build.lib.profiler.SilentCloseable;
 import com.google.devtools.build.lib.runtime.BlazeCommand;
@@ -48,7 +48,7 @@
       BuildRequestOptions.class,
       ExecutionOptions.class,
       LocalExecutionOptions.class,
-      PackageCacheOptions.class,
+      PackageOptions.class,
       AnalysisOptions.class,
       LoadingOptions.class,
       KeepGoingOption.class,
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/CanonicalizeCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/CanonicalizeCommand.java
index c18777e..24b1431 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/CanonicalizeCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/CanonicalizeCommand.java
@@ -16,7 +16,7 @@
 import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableList;
 import com.google.devtools.build.lib.events.Event;
-import com.google.devtools.build.lib.pkgcache.PackageCacheOptions;
+import com.google.devtools.build.lib.pkgcache.PackageOptions;
 import com.google.devtools.build.lib.runtime.BlazeCommand;
 import com.google.devtools.build.lib.runtime.BlazeCommandResult;
 import com.google.devtools.build.lib.runtime.BlazeCommandUtils;
@@ -44,7 +44,7 @@
 /** The 'blaze canonicalize-flags' command. */
 @Command(
     name = "canonicalize-flags",
-    options = {CanonicalizeCommand.Options.class, PackageCacheOptions.class},
+    options = {CanonicalizeCommand.Options.class, PackageOptions.class},
     // inherits from query to get proper package loading options.
     inherits = {QueryCommand.class},
     allowResidue = true,
@@ -149,9 +149,9 @@
             .add(FlagClashCanaryOptions.class)
             .build();
 
-    // set up the package cache for starlark options parsing
+    // set up the command environment for starlark options parsing
     try {
-      env.setupPackageCache(options);
+      env.syncPackageLoading(options);
     } catch (InterruptedException e) {
       env.getReporter().handle(Event.error("canonicalization interrupted"));
       return BlazeCommandResult.exitCode(ExitCode.INTERRUPTED);
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java
index 8941fd8..9dc5cc8 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoCommand.java
@@ -124,7 +124,7 @@
                 // In order to be able to answer configuration-specific queries, we need to set up
                 // the package path. Since info inherits all the build options, all the necessary
                 // information is available here.
-                env.setupPackageCache(optionsParsingResult);
+                env.syncPackageLoading(optionsParsingResult);
                 // TODO(bazel-team): What if there are multiple configurations? [multi-config]
                 return env.getSkyframeExecutor()
                     .getConfiguration(
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoItem.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoItem.java
index 9a5edc7..9697e88 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoItem.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/InfoItem.java
@@ -32,7 +32,7 @@
 import com.google.devtools.build.lib.packages.StarlarkSemanticsOptions;
 import com.google.devtools.build.lib.packages.TriState;
 import com.google.devtools.build.lib.packages.Type;
-import com.google.devtools.build.lib.pkgcache.PackageCacheOptions;
+import com.google.devtools.build.lib.pkgcache.PackageOptions;
 import com.google.devtools.build.lib.query2.proto.proto2api.Build.AllowedRuleClassInfo;
 import com.google.devtools.build.lib.query2.proto.proto2api.Build.AttributeDefinition;
 import com.google.devtools.build.lib.query2.proto.proto2api.Build.AttributeValue;
@@ -360,9 +360,8 @@
     public byte[] get(Supplier<BuildConfiguration> configurationSupplier, CommandEnvironment env)
         throws AbruptExitException {
       checkNotNull(commandOptions);
-      PackageCacheOptions packageCacheOptions =
-          commandOptions.getOptions(PackageCacheOptions.class);
-      return print(Joiner.on(":").join(packageCacheOptions.packagePath));
+      PackageOptions packageOptions = commandOptions.getOptions(PackageOptions.class);
+      return print(Joiner.on(":").join(packageOptions.packagePath));
     }
   }
 
@@ -794,8 +793,8 @@
     public byte[] get(Supplier<BuildConfiguration> configurationSupplier, CommandEnvironment env)
         throws AbruptExitException {
       checkNotNull(commandOptions);
-      return print(Joiner.on(":").join(
-          commandOptions.getOptions(PackageCacheOptions.class).packagePath));
+      return print(
+          Joiner.on(":").join(commandOptions.getOptions(PackageOptions.class).packagePath));
     }
   }
 
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/ProjectFileSupport.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/ProjectFileSupport.java
index 56a580f..b3de6d6 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/ProjectFileSupport.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/ProjectFileSupport.java
@@ -15,7 +15,7 @@
 
 import com.google.devtools.build.lib.events.Event;
 import com.google.devtools.build.lib.events.ExtendedEventHandler;
-import com.google.devtools.build.lib.pkgcache.PackageCacheOptions;
+import com.google.devtools.build.lib.pkgcache.PackageOptions;
 import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
 import com.google.devtools.build.lib.runtime.CommonCommandOptions;
 import com.google.devtools.build.lib.runtime.ProjectFile;
@@ -67,7 +67,7 @@
                   // external
                   // repositories, which we don't for project files.
                   null,
-                  optionsParser.getOptions(PackageCacheOptions.class).packagePath,
+                  optionsParser.getOptions(PackageOptions.class).packagePath,
                   eventHandler,
                   workspaceDir,
                   workingDir,
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java
index 19f3151..cc73f1d 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryCommand.java
@@ -15,7 +15,7 @@
 
 import com.google.devtools.build.lib.events.Event;
 import com.google.devtools.build.lib.packages.Target;
-import com.google.devtools.build.lib.pkgcache.PackageCacheOptions;
+import com.google.devtools.build.lib.pkgcache.PackageOptions;
 import com.google.devtools.build.lib.profiler.Profiler;
 import com.google.devtools.build.lib.profiler.SilentCloseable;
 import com.google.devtools.build.lib.query2.common.AbstractBlazeQueryEnvironment;
@@ -47,7 +47,7 @@
 @Command(
     name = "query",
     options = {
-      PackageCacheOptions.class,
+      PackageOptions.class,
       QueryOptions.class,
       KeepGoingOption.class,
       LoadingPhaseThreadsOption.class
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryEnvironmentBasedCommand.java b/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryEnvironmentBasedCommand.java
index f4f1f2c..b780add 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryEnvironmentBasedCommand.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/commands/QueryEnvironmentBasedCommand.java
@@ -95,7 +95,7 @@
     QueryOptions queryOptions = options.getOptions(QueryOptions.class);
 
     try {
-      env.setupPackageCache(options);
+      env.syncPackageLoading(options);
     } catch (InterruptedException e) {
       env.getReporter().handle(Event.error("query interrupted"));
       return BlazeCommandResult.exitCode(ExitCode.INTERRUPTED);
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java
index ac86a9c..f85a3f2 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SequencedSkyframeExecutor.java
@@ -54,7 +54,7 @@
 import com.google.devtools.build.lib.packages.StarlarkSemanticsOptions;
 import com.google.devtools.build.lib.packages.WorkspaceFileValue;
 import com.google.devtools.build.lib.packages.WorkspaceFileValue.WorkspaceFileKey;
-import com.google.devtools.build.lib.pkgcache.PackageCacheOptions;
+import com.google.devtools.build.lib.pkgcache.PackageOptions;
 import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
 import com.google.devtools.build.lib.profiler.Profiler;
 import com.google.devtools.build.lib.profiler.ProfilerTask;
@@ -226,7 +226,7 @@
   @Override
   public void sync(
       ExtendedEventHandler eventHandler,
-      PackageCacheOptions packageCacheOptions,
+      PackageOptions packageOptions,
       PathPackageLocator packageLocator,
       StarlarkSemanticsOptions starlarkSemanticsOptions,
       UUID commandId,
@@ -246,7 +246,7 @@
     }
     super.sync(
         eventHandler,
-        packageCacheOptions,
+        packageOptions,
         packageLocator,
         starlarkSemanticsOptions,
         commandId,
@@ -254,7 +254,7 @@
         tsgm,
         options);
     long startTime = System.nanoTime();
-    handleDiffs(eventHandler, packageCacheOptions.checkOutputFiles, options);
+    handleDiffs(eventHandler, packageOptions.checkOutputFiles, options);
     long stopTime = System.nanoTime();
     Profiler.instance().logSimpleTask(startTime, stopTime, ProfilerTask.INFO, "handleDiffs");
     long duration = stopTime - startTime;
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
index c1bc99a..c88c413 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java
@@ -117,8 +117,8 @@
 import com.google.devtools.build.lib.packages.StarlarkSemanticsOptions;
 import com.google.devtools.build.lib.packages.WorkspaceFileValue;
 import com.google.devtools.build.lib.pkgcache.LoadingOptions;
-import com.google.devtools.build.lib.pkgcache.PackageCacheOptions;
 import com.google.devtools.build.lib.pkgcache.PackageManager;
+import com.google.devtools.build.lib.pkgcache.PackageOptions;
 import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
 import com.google.devtools.build.lib.pkgcache.TargetParsingPhaseTimeEvent;
 import com.google.devtools.build.lib.pkgcache.TargetPatternPreloader;
@@ -1359,7 +1359,7 @@
   @VisibleForTesting // productionVisibility = Visibility.PRIVATE
   public void preparePackageLoading(
       PathPackageLocator pkgLocator,
-      PackageCacheOptions packageCacheOptions,
+      PackageOptions packageOptions,
       StarlarkSemanticsOptions starlarkSemanticsOptions,
       UUID commandId,
       Map<String, String> clientEnv,
@@ -1372,18 +1372,18 @@
     setCommandId(commandId);
     this.clientEnv.set(clientEnv);
 
-    setShowLoadingProgress(packageCacheOptions.showLoadingProgress);
-    setDefaultVisibility(packageCacheOptions.defaultVisibility);
+    setShowLoadingProgress(packageOptions.showLoadingProgress);
+    setDefaultVisibility(packageOptions.defaultVisibility);
 
     StarlarkSemantics starlarkSemantics = getEffectiveStarlarkSemantics(starlarkSemanticsOptions);
     setSkylarkSemantics(starlarkSemantics);
     setSiblingDirectoryLayout(starlarkSemantics.experimentalSiblingRepositoryLayout());
     setPackageLocator(pkgLocator);
 
-    syscalls.set(getPerBuildSyscallCache(packageCacheOptions.globbingThreads));
-    this.pkgFactory.setGlobbingThreads(packageCacheOptions.globbingThreads);
+    syscalls.set(getPerBuildSyscallCache(packageOptions.globbingThreads));
+    this.pkgFactory.setGlobbingThreads(packageOptions.globbingThreads);
     this.pkgFactory.setMaxDirectoriesToEagerlyVisitInGlobbing(
-        packageCacheOptions.maxDirectoriesToEagerlyVisitInGlobbing);
+        packageOptions.maxDirectoriesToEagerlyVisitInGlobbing);
     emittedEventState.clear();
 
     // If the PackageFunction was interrupted, there may be stale entries here.
@@ -2642,7 +2642,7 @@
    */
   public void sync(
       ExtendedEventHandler eventHandler,
-      PackageCacheOptions packageCacheOptions,
+      PackageOptions packageOptions,
       PathPackageLocator pathPackageLocator,
       StarlarkSemanticsOptions starlarkSemanticsOptions,
       UUID commandId,
@@ -2680,7 +2680,7 @@
     }
     setRemoteExecutionEnabled(remoteOptions != null && remoteOptions.isRemoteExecutionEnabled());
     syncPackageLoading(
-        packageCacheOptions,
+        packageOptions,
         pathPackageLocator,
         starlarkSemanticsOptions,
         commandId,
@@ -2708,7 +2708,7 @@
   }
 
   protected void syncPackageLoading(
-      PackageCacheOptions packageCacheOptions,
+      PackageOptions packageOptions,
       PathPackageLocator pathPackageLocator,
       StarlarkSemanticsOptions starlarkSemanticsOptions,
       UUID commandId,
@@ -2718,15 +2718,10 @@
       throws AbruptExitException {
     try (SilentCloseable c = Profiler.instance().profile("preparePackageLoading")) {
       preparePackageLoading(
-          pathPackageLocator,
-          packageCacheOptions,
-          starlarkSemanticsOptions,
-          commandId,
-          clientEnv,
-          tsgm);
+          pathPackageLocator, packageOptions, starlarkSemanticsOptions, commandId, clientEnv, tsgm);
     }
     try (SilentCloseable c = Profiler.instance().profile("setDeletedPackages")) {
-      setDeletedPackages(packageCacheOptions.getDeletedPackages());
+      setDeletedPackages(packageOptions.getDeletedPackages());
     }
 
     incrementalBuildMonitor = new SkyframeIncrementalBuildMonitor();