Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Cycle in the workspace file detected #225

Open
daniel-b2c2 opened this issue Sep 25, 2024 · 6 comments
Open

Bug: Cycle in the workspace file detected #225

daniel-b2c2 opened this issue Sep 25, 2024 · 6 comments

Comments

@daniel-b2c2
Copy link

As reported here:

bazel-contrib/bazel_features#70 (comment)

Cycle in the workspace file detected. This indicates that a repository is used prior to being defined.
The following chain of repository dependencies lead to the missing definition.
 - @@bazel_features
This could either mean you have to add the '@@bazel_features' repository with a statement like `http_archive` in your WORKSPACE file (note that transitive dependencies are not added automatically), or move an existing definition earlier in your WORKSPACE file.
Computing main repo mapping:
ERROR: Error computing the main repository mapping: cycles detected during computation of main repo mapping

I'm not an expert, just somebody who wants to see this fixed after having to upgrade:

Overheard:

I'm pretty sure that the bug is in the transitively updated rules_java, which is used by Bazel's workspace suffix but doesn't properly declare the dep on bazel_features here: https://github.com/bazelbuild/rules_java/blob/master/java/repositories.bzl

Please advise if the issue above is caused by rules_java, or if the problem sits elsewhere

@fmeum
Copy link
Contributor

fmeum commented Oct 2, 2024

I looked into this in detail now and can report that the full cycle is:

[Key{repoName=@@, rootModuleShouldSeeWorkspaceRepos=true}, external, com.google.devtools.build.lib.skyframe.ExternalPackageFunction$$Lambda/0x000000700120e428@cee2c26] -> [[/Users/fmeum/git/hirschgarten]/[WORKSPACE], 4, KeyForWorkspace{label=@@rules_sonatype//:defs.bzl, isBuildPrelude=false}, KeyForWorkspace{label=@@rules_sonatype//private/rules:sonatype_java_export.bzl, isBuildPrelude=false}, KeyForWorkspace{label=@@rules_jvm_external~//:defs.bzl, isBuildPrelude=false}, KeyForWorkspace{label=@@rules_jvm_external~//private/rules:maven_bom.bzl, isBuildPrelude=false}, KeyForWorkspace{label=@@bazel_features//:features.bzl, isBuildPrelude=false}, CONTAINING_PACKAGE_LOOKUP:@@bazel_features//, PACKAGE_LOOKUP:@@bazel_features//, REPOSITORY_DIRECTORY:@@bazel_features]

So rules_java isn't at fault here (sorry about the false alarm). Instead, bazel-contrib/rules_jvm_external@3df00a6 introduced a dependency of rules_jvm_external on bazel_features, but https://github.com/JetBrains/hirschgarten/blob/bazel-steward/rules_jvm_external/6.4/WORKSPACE.bzlmod doesn't properly instantiate the WORKSPACE dependency macro of rules_jvm_external, which is a transitive dep of rules_sonatype but not listed in its deps section at https://github.com/JetBrains/hirschgarten/tree/main/rules_sonatype.

@gergelyfabian
Copy link

I don't know whether it changes anything but I can reproduce this issue without using bzlmod.

@agluszak
Copy link

agluszak commented Oct 4, 2024

@gergelyfabian and without using rules_sonatype?

@gergelyfabian
Copy link

According to my knowledge no sonatype in this project.

@gergelyfabian
Copy link

Checked while still using rules_jvm_external 6.3:

$ bazel query --output=build //external:rules_sonatype
ERROR: no such target '//external:rules_sonatype': target 'rules_sonatype' not declared in package 'external' defined by myproject/WORKSPACE

@gergelyfabian
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants