bazelbuild / bazelbuild/bazel

Vendor mode does not show why an external repository is invalidated

Open
#23,243 21 comments 1 reaction 0 assignees View on GitHub
P2 team-ExternalDeps type: bug
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### 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

$ bazel fetch //... # Is this needed? It does not seem to help.

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

$ rm -rf
$ 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.

Contributor guide

Open the contributing guide

Research direction

Reproduce the sequence of `bazel vendor //target`, cache removal, and `bazel test //target` with fetching disabled, following the airgapped-build instructions linked in the issue. Inspect how the listed external repositories, including `@local_config_platform` and `@bazel_tools`, are resolved during vendor mode. Done means the vendored directory supports the reported airgapped build without requiring network access or the removed local cache.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.