bazel-contrib / bazel_features

Support Bazel "feature detection" from starlark
https://docs.google.com/document/d/1HJf3gMYIrzmTRqbD4nWXH2eJRHXjLrOU0mmIeZplUzY/edit#heading=h.5mcn15i0e1ch
Apache License 2.0
19 stars 15 forks source link

Possible bug in `bazel_features` causing problem updating `rules_jvm_external` depndency #70

Closed hb-man closed 1 month ago

hb-man commented 1 month ago

Not sure in which of two projects the problem is https://github.com/bazel-contrib/rules_jvm_external/issues/1256

Updating rules_jvm_external to version 6.4 causes bazel_features error

can be reproduced on this project/branch

https://github.com/JetBrains/hirschgarten/pull/68

full error message:

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 tried fixing it by adding explicit dependency to bazel_features - but than i get another error:

ERROR: Failed to load Starlark extension '@@bazel_features_version//:version.bzl'.
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_version
This could either mean you have to add the '@@bazel_features_version' 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.
ERROR: Error computing the main repository mapping: cycles detected during computation of main repo mapping

Though, if I add bazel_features depndency explicit, but WORKSPACE-style - it starts to work. This might be a bug in bazel features so I'll file it there.

fmeum commented 1 month ago

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

@hvadehra

daniel-b2c2 commented 1 month ago

@fmeum so the issue should be raised in rules_java project?

fmeum commented 1 month ago

@daniel-b2c2 Yes, please do!

fmeum commented 1 month ago

See https://github.com/bazelbuild/rules_java/issues/225#issuecomment-2388494967, a closer look revealed that this is an issue with rules_sonatype.