-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Bazel 7.0.1 reports cyclic dependency in rules_python #20942
Comments
Hm, odd. Trying to build in the root of rules_python gives that failure, but not when building in one of the child workspaces. So that's good news -- maybe this is just localized to something about rules_python's root setup |
Pointed to an innocent looking commit (39b9954); I can't imagine why retrying ipv6 binding would be the culprit. So the commit must be somewhere between 7.0.0 and that commit? There's only 20 commits (7.0.0...7.0.1), so this shouldn't be too hard to narrow down. I see a few changes to repo mapping stuff, which seem like likely culprits. Still odd that 8.x doesn't have this problem. |
huh. I tried the same bisect, with
|
A manual linear-sect pointed at ce993c4 as the culprit. Building with cc @fmeum @meteorcloudy @SalmaSamy Now to find out:
Will keep investigating tomorrow. |
I found a faster repro is to build |
Yeah, the lockfile seems to be related. Setting After running bisects, I then ran the original repro command: success
Thanks! We can add --lockfile_mode=off to our bazelrc to work around this in the meantime. The only thing special about rules_python repo/module stuff I can think of is it sets os/arch dependent=True. I tried modifying internal_config_repo.bzl in various ways, but the error persists. When I simplify it down to a no-op -- a repo rule that creates nothing but an empty BUILD file, the first build gives a (correct and expected) error about a load() failing because the repo is missing a file (because it wasn't generated). The second build gives the cyclic dependency error. Setting lockfile_mode=off makes it go back to giving the first error. (I mention this because that's the only thing mentioned in the error, and just wanted to make sure it's not related to what that repo rule is doing; it appears not) |
Bazel 7.0.1 has a bug where lockfiles can cause a bogus error about cyclic dependencies. Removing the lockfile or disabling the lockfiles prevents it from triggering. See bazelbuild/bazel#20942
The cycle:
This suggests the workaround of |
A linear bisect on my machine, where I delete Edit: This makes sense as the cause: Validating the up-to-dateness of main repo mapping entries requests the full repo mapping, which causes a cycle if WORKSPACE evaluation, which is needed for the full repo mapping, also depends on a module extension with recorded repo mapping entries. The internal deps extension has such entries:
I'm not sure how to fix this. The chunked nature of WORKSPACE means that we only learn its repo mapping step by step and we certainly don't want to have a special repo mapping key for each chunk. |
Maybe we could pretend that repo mappings aren't used in WORKSPACE and restrict the recording and verification to the main repo mapping without WORKSPACE repos? |
SGTM, repos from WORKSPACE should not have any effect on Bzlmod resolution anyway. |
…1705) Bazel 7.0.1 has a bug where lockfiles can cause a bogus error about cyclic dependencies. Removing the lockfile or disabling the lockfiles prevents it from triggering. We aren't using lockfiles anyways. This should make CI happy, which uses 7.0.1 in some configurations. Local development isn't impacted because .bazelversion specifies 7.0.0 See bazelbuild/bazel#20942
Amazing detective work, @fmeum !
This is a bit easier said than done -- at "recording" time, we don't actually know whether a repo mapping entry is from WORKSPACE or Bzlmod. Verification time, sure -- that's easy; we could just request The good thing is, I think that's exactly what we should do. This cycle only appears when we're running an extension in the main repo, which exactly matches this case. I'll try to see if doing this fixes the issue. |
Hmm. I still wonder why this doesn't happen with HEAD Bazel, but solving that particular mystery is lower priority. |
Ah, I think I figured out why this confused This also explains why it wasn't failing with HEAD Bazel: it actual is failing with HEAD Bazel if you make sure to delete the lockfile first and then build twice. In happier news, the trick I described works. Will send a PR soon. |
…extension eval See code comment and linked issue for more information. Fixes #20942.
@bazel-io fork 7.0.2 |
…extension eval See code comment and linked issue for more information. Fixes bazelbuild#20942. Closes bazelbuild#20982. PiperOrigin-RevId: 600856392 Change-Id: I5b8a0ed3a38e37ab51ffb49b19a59f2e161b9a33
@bazel-io fork 7.1.0 |
…ries in extension eval (#21003) See code comment and linked issue for more information. Fixes #20942. Closes #20982. Commit 21508b1 PiperOrigin-RevId: 600856392 Change-Id: I5b8a0ed3a38e37ab51ffb49b19a59f2e161b9a33 --------- Co-authored-by: Xdng Yng <[email protected]>
Work towards #20942 On the referenced bug, this prints: ``` ERROR: Circular definition of repositories generated by module extensions and/or .bzl files: .-> repository mapping of @@ | WORKSPACE file | //python:pip.bzl | //python/pip_install:requirements.bzl | //python:defs.bzl | //python:py_import.bzl | //python:py_info.bzl | @@_main~internal_deps~rules_python_internal//:rules_python_config.bzl | @@_main~internal_deps~rules_python_internal | extension 'internal_deps' defined in //python/private/bzlmod:internal_deps.bzl `-- repository mapping of @@ ERROR: Error computing the main repository mapping: cycles detected during computation of main repo mapping ``` Closes #20958. PiperOrigin-RevId: 601183514 Change-Id: If321005b1f6918117d0f5b5763ae2bda4d8e34f1
Work towards bazelbuild#20942 On the referenced bug, this prints: ``` ERROR: Circular definition of repositories generated by module extensions and/or .bzl files: .-> repository mapping of @@ | WORKSPACE file | //python:pip.bzl | //python/pip_install:requirements.bzl | //python:defs.bzl | //python:py_import.bzl | //python:py_info.bzl | @@_main~internal_deps~rules_python_internal//:rules_python_config.bzl | @@_main~internal_deps~rules_python_internal | extension 'internal_deps' defined in //python/private/bzlmod:internal_deps.bzl `-- repository mapping of @@ ERROR: Error computing the main repository mapping: cycles detected during computation of main repo mapping ``` Closes bazelbuild#20958. PiperOrigin-RevId: 601183514 Change-Id: If321005b1f6918117d0f5b5763ae2bda4d8e34f1
…porter (#21013) Work towards #20942 On the referenced bug, this prints: ``` ERROR: Circular definition of repositories generated by module extensions and/or .bzl files: .-> repository mapping of @@ | WORKSPACE file | //python:pip.bzl | //python/pip_install:requirements.bzl | //python:defs.bzl | //python:py_import.bzl | //python:py_info.bzl | @@_main~internal_deps~rules_python_internal//:rules_python_config.bzl | @@_main~internal_deps~rules_python_internal | extension 'internal_deps' defined in //python/private/bzlmod:internal_deps.bzl `-- repository mapping of @@ ERROR: Error computing the main repository mapping: cycles detected during computation of main repo mapping ``` Closes #20958. Commit fab6414 PiperOrigin-RevId: 601183514 Change-Id: If321005b1f6918117d0f5b5763ae2bda4d8e34f1 Co-authored-by: Fabian Meumertzheim <[email protected]>
A fix for this issue has been included in Bazel 7.0.2 RC1. Please test out the release candidate and report any issues as soon as possible. Thanks! |
Description of the bug:
Bazel 7.0.1 reports a cyclic dependency in rules_python. However, 7.0.0 and the 8.x/rolling releases don't exhibit this bug
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.
Checkout rules python, enable the starlark implementation, and build with 7.0.1
The 7.0.0 release and rolling (8.x) releases don't have this problem
See also: https://buildkite.com/bazel/rules-python-python/builds/6938#018d1ee3-ca77-4167-bcce-3ac335c7d203
The error is
Which operating system are you running Bazel on?
linux
What is the output of
bazel info release
?release 7.0.1
If
bazel info release
returnsdevelopment 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 master; git rev-parse HEAD
?Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
Yes. Not sure, I'll look into it. Just want to file this sooner rather than later
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: