Skip to content

Bazel crashes when using bzlmod and a registry with an incorrect bazel_registry.json file  #14437

@danielmachlab

Description

@danielmachlab

Description of the problem / feature request:

Bazel crashes due to an internal error when using a bzlmod registry that doesn't correctly specify a bazel_registry.json file. The stack-trace printed by Bazel when it crashes is included in the last section below.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

To demonstrate this bug, I created a fork of the bazel-central-repository and made a single commit that deletes the contents of the bazel_registry.json file. I also created an bazelmod_example repository that has a dependency on zlib.

To reproduce the bug:

  1. Install bazelisk
  2. git clone https://github.com/danielmachlab/bzlmod_example
  3. bazelisk build src:hello-world --experimental_enable_bzlmod to demonstrate the example works when using the bazel-central-repository
  4. bazelisk build src:hello-world --experimental_enable_bzlmod --registry https://danielmachlab.github.io/bazel-central-registry/ to reproduce the bug by using the forked version of the bazel-central-repository, which contained an empty bazel_registry.json file

What operating system are you running Bazel on?

MacOS Big Sur 11.5.2

What's the output of bazel info release?

2021/12/15 15:52:43 Using unreleased version at commit 4c6e324dfab9444fc51b9fb3f5074a01889725e1
Starting local Bazel server and connecting to it...
development version

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

I am using bazelisk with a .bazeliskrc file containing:

USE_BAZEL_VERSION=last_green

Have you found anything relevant by searching the web?

I haven't found anything specific to this issue, but I have been referencing the following resources:
bzlmod user guide
Bazel External Dependencies Overhaul Google Doc

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

This is the stack trace printed after Bazel crashes:

machlabda@machlabda-a01 bzlmod_example % bazel build src:hello-world --registry https://danielmachlab.github.io/bazel-central-registry/ 
2021/12/15 15:50:14 Using unreleased version at commit 4c6e324dfab9444fc51b9fb3f5074a01889725e1
Analyzing: target //src:hello-world (0 packages loaded, 0 targets configured)
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.RuntimeException: Unrecoverable error while evaluating node 'BZLMOD_REPO_RULE:zlib.1.2.11' (requested by nodes 'REPOSITORY_DIRECTORY:@zlib.1.2.11')
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:667)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:382)
        at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: java.lang.NullPointerException
        at java.base/java.util.Objects.requireNonNull(Unknown Source)
        at java.base/java.util.Optional.<init>(Unknown Source)
        at java.base/java.util.Optional.of(Unknown Source)
        at com.google.devtools.build.lib.bazel.bzlmod.IndexRegistry.grabJson(IndexRegistry.java:118)
        at com.google.devtools.build.lib.bazel.bzlmod.IndexRegistry.getRepoSpec(IndexRegistry.java:125)
        at com.google.devtools.build.lib.bazel.bzlmod.BzlmodRepoRuleHelperImpl.checkRepoFromBazelModules(BzlmodRepoRuleHelperImpl.java:83)
        at com.google.devtools.build.lib.bazel.bzlmod.BzlmodRepoRuleHelperImpl.getRepoSpec(BzlmodRepoRuleHelperImpl.java:56)
        at com.google.devtools.build.lib.skyframe.BzlmodRepoRuleFunction.compute(BzlmodRepoRuleFunction.java:129)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:591)
        ... 7 more

Metadata

Metadata

Assignees

Labels

area-BzlmodBzlmod-specific PRs, issues, and feature requestsgood first issuehelp wantedSomeone outside the Bazel team could own thisteam-ExternalDepsExternal dependency handling, remote repositiories, WORKSPACE file.type: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions