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

fetch no longer works for targets ending in ... #21728

Closed
jfirebaugh opened this issue Mar 19, 2024 · 13 comments
Closed

fetch no longer works for targets ending in ... #21728

jfirebaugh opened this issue Mar 19, 2024 · 13 comments
Assignees
Labels
P1 I'll work on this now. (Assignee required) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug

Comments

@jfirebaugh
Copy link

Description of the bug:

Bazel 7.1.0 has a breaking change to bazel fetch. It's no longer possible to fetch target labels ending in ....

Which category does this issue belong to?

No response

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

$ bazel fetch @go_sdk//...  
INFO: Analyzed 59 targets (0 packages loaded, 0 targets configured).
INFO: Found 59 targets...
ERROR: Error doing post analysis query: Evaluation failed: Unable to load package '[/private/var/tmp/_bazel_john/67beefda950d56283b98d96980e6e332/external/go_sdk]/[]' because package is not in scope. Check that all target patterns in query expression are within the --universe_scope of this query.
INFO: Elapsed time: 0.543s, Critical Path: 0.00s
INFO: 0 processes.
ERROR: Build did NOT complete successfully
ERROR: Fetching some target dependencies for deps(@go_sdk//...) failed, but --keep_going specified.  Ignoring errors

Which operating system are you running Bazel on?

macOS

What is the output of bazel info release?

release 7.1.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 ?

n/a

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

Yes

Have you found anything relevant by searching the web?

No response

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

No response

@Wyverald Wyverald added P1 I'll work on this now. (Assignee required) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. and removed untriaged labels Mar 19, 2024
@Wyverald Wyverald assigned SalmaSamy and unassigned sgowroji and iancha1992 Mar 19, 2024
@Wyverald
Copy link
Member

Context: 7.1.0 we switched bazel fetch X from performing a bazel query deps(X) to bazel cquery deps(X). Looks like cquery somehow requires --universe_scope for target patterns with ...? I wonder if we could just specify a default universe scope of "everything" and be done with it.

cc @meteorcloudy; @haxorz (for --universe_scope insights); @gregestren (for cquery insights)

@Wyverald
Copy link
Member

@bazel-io fork 7.1.1

@Wyverald
Copy link
Member

If this is nontrivial to fix, we might need to roll back the query->cquery change. It's had too many unforeseen backward incompatibilities.

@SalmaSamy
Copy link
Contributor

I think widening the scope of the query is the solution, but I am not sure making the default scope 'everything' is a good idea as it may make fetch very slow and would also fetch more than needed in other cases.

I guess this issue is common with external repos? so maybe something like: if the target is external, add the repo to the query universe-scope?

@meteorcloudy
Copy link
Member

meteorcloudy commented Mar 19, 2024

What is the default --universe_scope when doing bazel fetch @go_sdk//...? Is there a reproducible case? I tried locally to fetch some simple repos like @platforms//... and it worked.

@meteorcloudy
Copy link
Member

OK, I can reproduce with rules_go:

pcloudy@pcloudy-macbookpro3:~/workspace/rules_go (master)
$ bazel fetch @go_sdk//...
Starting local Bazel server and connecting to it...
INFO: Invocation ID: 7ae0f9bf-4a35-4f08-93ff-af1c3fe85342
INFO: Options provided by the client:
  Inherited 'common' options: --isatty=1 --terminal_columns=164
INFO: Reading rc options for 'fetch' from /Users/pcloudy/workspace/rules_go/.bazelrc:
  Inherited 'common' options: --enable_platform_specific_config --noexperimental_enable_bzlmod
INFO: Reading rc options for 'fetch' from /Users/pcloudy/.bazelrc:
  Inherited 'build' options: --verbose_failures --announce_rc --disk_cache=/tmp/bazel_disk_cache --repository_cache=/tmp/bazel_repository_cache
INFO: Reading rc options for 'fetch' from /Users/pcloudy/workspace/rules_go/.bazelrc:
  Inherited 'test' options: --test_output=errors
INFO: Reading rc options for 'fetch' from /Users/pcloudy/.bazelrc:
  Inherited 'test' options: -k --test_output=errors
INFO: Analyzed 59 targets (10 packages loaded, 9364 targets configured).
INFO: Found 59 targets...
ERROR: Error doing post analysis query: Unable to load package '[/private/var/tmp/_bazel_pcloudy/47a70700a1df689551e6f1da93464795/external/go_sdk]/[]' because package is not in scope. Check that all target patterns in query expression are within the --universe_scope of this query.
INFO: Elapsed time: 15.051s, Critical Path: 0.00s
INFO: 0 processes.
INFO: Build completed successfully, 0 total actions
INFO: All external dependencies for these targets fetched successfully.

@SalmaSamy
Copy link
Contributor

@meteorcloudy The default should be the targets parsed from the query expression, basically the same targets you're trying to fetch.
So for '@go_sdk//...' it should actually be '@go_sdk//...' which should work! but according to this, it may still not work :|

@Wyverald
Copy link
Member

I dug around a bit with help from @gregestren. It appears that cquery itself doesn't support this query (i.e. bazel cquery @go_sdk//... fails with the exact same error message). It's unclear to me what value of --universe_scope will make the query succeed.

In the interest of not blocking 7.1.1 further, I'm going to revert the original change in 7.1.0.

@iancha1992
Copy link
Member

A fix for this issue has been included in Bazel 7.1.1 RC2. Please test out the release candidate and report any issues as soon as possible.
If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=7.1.1rc2. Thanks!

@meteorcloudy
Copy link
Member

I wonder why we have to use cquery? Can we implement bazel fetch as bazel build --nobuild <target> instead?

@SalmaSamy
Copy link
Contributor

I wonder why we have to use cquery? Can we implement bazel fetch as bazel build --nobuild <target> instead?

Tried that and it seems to work :)

@brentleyjones
Copy link
Contributor

@bazel-io flag

@bazel-io bazel-io added the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Mar 27, 2024
@iancha1992
Copy link
Member

@bazel-io fork 7.2.0

@bazel-io bazel-io removed the potential release blocker Flagged by community members using "@bazel-io flag". Should be added to a release blocker milestone label Mar 27, 2024
SalmaSamy added a commit that referenced this issue Mar 28, 2024
Using cquery for fetching targets caused some problems #21728 as cquery is not prepared to deal with targets including `...`

Updated the logic to use build command with no-build option, which should operate the same and actually do less work than cquery

PiperOrigin-RevId: 619540572
Change-Id: Id26a61229c13bd12373478fe17e67200f2760be2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 I'll work on this now. (Assignee required) team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug
Projects
None yet
Development

No branches or pull requests

8 participants