bazel: Vendor mode does not show why an external repository is invalidated

Description of the bug:

Bazel vendor command produces a directory with dependencies.

However, it is impossible to build or run any targets on an airgapped system with the produced directory.

Bazel still requires access to network (or access to the cache that was in use while building vendor directory).

According to https://github.com/bazelbuild/bazel/issues/19563#issuecomment-2113515116, airgapped builds should be possible.

Which category does this issue belong to?

Core

What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Testing this in 7.3.0rc2:

$ bazel vendor //target
<Completes successfully, produces several gigabytes of dependencies in vendor directory, which will later be copied to an airgapped system>
$ bazel fetch //...  # Is this needed? It does not seem to help.

... Disconnect from network or add --nofetch to .bazelrc ...

$ rm -rf <bazel local cache directory>  
$ bazel test //target
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
ERROR: Error computing the main repository mapping: error during computation of main repo mapping: to fix, run
        bazel fetch //...
External repository @@local_config_platform not found and fetching repositories is disabled.

Sometimes the error is:

External repository @@bazel_tools not found and fetching repositories is disabled.

Same happens when running bazel vendor without a particular target. Without removing local cache bazel test works fine on local system, but obviously will fail on an airgapped host.

Is there a setting I am missing?

It looks like bazel is having difficulty resolving approximately the following after cache is removed:

@local_config_platform//:all
@local_config_sh//:all
@@local_config_cc_toolchains//:all
@@local_jdk//:all
@@rules_java//:all

Running bazel vendor with each of the above does not help.

Which operating system are you running Bazel on?

any

What is the output of bazel info release?

release 7.3.0rc2

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What’s the output of git remote get-url origin; git rev-parse HEAD ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

Instructions at https://bazel.build/run/build#running-bazel-airgapped do not resolve the problem.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 1
  • Comments: 21 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I’m working on a PR that prints the reason for an outdated repo.

$ bazel build --repository_cache= //experimental:tests

You are missing --vendor_dir flag, without this flag, the vendor source won’t be used.