bazel: Bazel crashes using external aspect + `--noenable_workspace`
Description of the bug:
With bzlmod and the –noenable_workspace option, Bazel crashes when we try to use an external aspect defined by the –aspects and –override_repository options.
$ bazel build \
--enable_bzlmod \
--noenable_workspace \
--aspects=@@foo//:foo.bzl%foo_aspect \
--override_repository=foo=%workspace%/foo \
//...
Analyzing: target //:dummy (1 packages loaded, 0 targets configured)
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.IllegalStateException: Evaluation of SkyKey failed and no dependencies were requested: KeyForBuild{label=@@foo//:foo.bzl, isBuildPrelude=false} IncrementalInMemoryNodeEntry{key=KeyForBuild{label=@@foo//:foo.bzl, isBuildPrelude=false}, value=null, dirtyBuildingState=InitialBuildingState{dirtyState=REBUILDING, signaledDeps=5, externalDeps=0, dirtyDirectDepIndex=0}, version=com.google.devtools.build.skyframe.Version$MinimalVersion@5937f9c0, directDeps=GroupedDeps{size=5, elements=[Starlark @_builtins, CONTAINING_PACKAGE_LOOKUP:@@foo//, FILE:[<output_base>/external/foo]/[foo.bzl], PRECOMPUTED:starlark_semantics, Key{repoName=@@foo, rootModuleShouldSeeWorkspaceRepos=true}]}, reverseDeps=ReverseDeps{reverseDeps=[], singleReverseDep=false, dataToConsolidate=[BuildTopLevelAspectsDetailsKey{topLevelAspectsClasses=[@@foo//:foo.bzl%foo_aspect], topLevelAspectsParameters={}}]}}
at com.google.common.base.Preconditions.checkState(Preconditions.java:835)
at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:690)
at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:414)
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)
- No problem with
--enable_workspaceoption. - No problem when passing a missing bzl file in the
--aspectsoption, e.g--aspects=@@foo//:xxx.bzl%foo_aspect. - Same problem when passing a non exported symbol in the
--aspectsoption, e.g--aspects=@@foo//:foo.bzl%xxx. - Same problem with Bazel
7.1.2.
Which category does this issue belong to?
Core, External Dependency
What’s the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
.
├── .bazelversion
├── BUILD.bazel
├── foo
│ ├── BUILD.bazel
│ ├── foo.bzl
│ └── WORKSPACE
├── MODULE.bazel
├── WORKSPACE
└── WORKSPACE.bzlmod
.bazelversion
7.2.0
BUILD.bazel
genrule(
name = "dummy",
outs = ["dummy.txt"],
cmd = "touch $@",
)
foo/foo.bzl
def _foo_aspect_impl(target, ctx):
return []
foo_aspect = aspect(
implementation = _foo_aspect_impl,
)
foo/WORKSPACE
workspace(name = "foo")
MODULE.bazel
module(name = "my_workspace")
WORKSPACE
workspace(name = "my_workspace")
$ bazel build \
--enable_bzlmod \
--noenable_workspace \
--lockfile_mode=off \
--aspects=@@foo//:foo.bzl%foo_aspect \
--override_repository=foo=%workspace%/foo \
-- //...
Starting local Bazel server and connecting to it...
Analyzing: target //:dummy (2 packages loaded, 0 targets configured)
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.IllegalStateException: Evaluation of SkyKey failed and no dependencies were requested: KeyForBuild{label=@@foo//:foo.bzl, isBuildPrelude=false} IncrementalInMemoryNodeEntry{key=KeyForBuild{label=@@foo//:foo.bzl, isBuildPrelude=false}, value=null, dirtyBuildingState=InitialBuildingState{dirtyState=REBUILDING, signaledDeps=5, externalDeps=0, dirtyDirectDepIndex=0}, version=com.google.devtools.build.skyframe.Version$MinimalVersion@5ba14436, directDeps=GroupedDeps{size=5, elements=[Starlark @_builtins, CONTAINING_PACKAGE_LOOKUP:@@foo//, FILE:[<output_base>/external/foo]/[foo.bzl], PRECOMPUTED:starlark_semantics, Key{repoName=@@foo, rootModuleShouldSeeWorkspaceRepos=true}]}, reverseDeps=ReverseDeps{reverseDeps=[], singleReverseDep=false, dataToConsolidate=[BuildTopLevelAspectsDetailsKey{topLevelAspectsClasses=[@@foo//:foo.bzl%foo_aspect], topLevelAspectsParameters={}}]}}
at com.google.common.base.Preconditions.checkState(Preconditions.java:835)
at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:690)
at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:414)
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)
Which operating system are you running Bazel on?
Linux / amd64
What is the output of bazel info release?
release 7.2.0
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?
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 15 (5 by maintainers)
Commits related to this issue
- Don't HTML escape `bazel mod` JSON output Otherwise `"<root>"` ends up being escaped with Unicode escape sequences, which is unnecessarily complex. Work towards #22691 Closes #23785. PiperOrigin-R... — committed to bazelbuild/bazel by fmeum 2 years ago
- Don't HTML escape `bazel mod` JSON output Otherwise `"<root>"` ends up being escaped with Unicode escape sequences, which is unnecessarily complex. Work towards #22691 Closes #23785. PiperOrigin-R... — committed to bazel-io/bazel by fmeum 2 years ago
- [7.4.0] Don't HTML escape `bazel mod` JSON output (#23819) Otherwise `"<root>"` ends up being escaped with Unicode escape sequences, which is unnecessarily complex. Work towards #22691 Closes #2378... — committed to bazelbuild/bazel by bazel-io 2 years ago
- Disable bazel deps call. It's unused yet, and could fail https://github.com/bazelbuild/bazel/issues/22691 — committed to tpasternak/bazel-intellij by deleted user 2 years ago
- Disable bazel deps call. It's unused yet, and could fail (#6860) * Disable bazel deps call. It's unused yet, and could fail https://github.com/bazelbuild/bazel/issues/22691 — committed to bazelbuild/intellij by deleted user 2 years ago
- Include apparent names of deps in `bazel mod` JSON output This allows IDEs to query for the direct dependencies of the root module as well as how they can refer to them from the point of view of the ... — committed to bazelbuild/bazel by fmeum 2 years ago
- Include apparent names of deps in `bazel mod` JSON output This allows IDEs to query for the direct dependencies of the root module as well as how they can refer to them from the point of view of the ... — committed to bazel-io/bazel by fmeum 2 years ago
- [8.0.0] Include apparent names of deps in `bazel mod` JSON output (#24234) This allows IDEs to query for the direct dependencies of the root module as well as how they can refer to them from the poin... — committed to bazelbuild/bazel by bazel-io 2 years ago
- [8.0.0] Include apparent names of deps in `bazel mod` JSON output (#24234) This allows IDEs to query for the direct dependencies of the root module as well as how they can refer to them from the poin... — committed to bazelbuild/bazel by bazel-io 2 years ago
- Add `--inject_repository` and fix crash on overridden non-existent repo Suggest the new flag instead of crashing when `--override_repository` is applied to a non-existent repo with `--noenable_worksp... — committed to bazelbuild/bazel by fmeum 2 years ago
- Add `--inject_repository` and fix crash on overridden non-existent repo Suggest the new flag instead of crashing when `--override_repository` is applied to a non-existent repo with `--noenable_worksp... — committed to schiele/bazel by fmeum 2 years ago
- [8.0.0] Add `--inject_repository` and fix crash on overridden non-existent repo (#24301) Suggest the new flag instead of crashing when `--override_repository` is applied to a non-existent repo with `... — committed to bazelbuild/bazel by Wyverald 2 years ago
- Include apparent names of deps in `bazel mod` JSON output This allows IDEs to query for the direct dependencies of the root module as well as how they can refer to them from the point of view of the ... — committed to bitrise-io/bazel by fmeum 2 years ago
- Add `--inject_repository` and fix crash on overridden non-existent repo Suggest the new flag instead of crashing when `--override_repository` is applied to a non-existent repo with `--noenable_worksp... — committed to bitrise-io/bazel by fmeum 2 years ago
- [7.5.0] Include apparent names of deps in `bazel mod` JSON output This allows IDEs to query for the direct dependencies of the root module as well as how they can refer to them from the point of view... — committed to fmeum/bazel by fmeum 2 years ago
- [7.5.0] Include apparent names of deps in `bazel mod` JSON output (#24847) This allows IDEs to query for the direct dependencies of the root module as well as how they can refer to them from the poin... — committed to bazelbuild/bazel by fmeum 2 years ago
I have no direct use for it. However, the Bazel plugin for Intellij yes. This plugin needs to execute a command similar to the one below:
I mitigated the problem by configuring the option
--enable_workspaceoption in the build_flags to override the--noenable_workspaceoption of my.bazelrcfile.Yes. The other required PR, the one that adds apparent names to
bazel mod depsJSON output, has already been merged into the Bazel 8 branch.