aspect-build / aspect-cli

correct, fast, usable: choose three
https://aspect.build/cli
Apache License 2.0
93 stars 21 forks source link

[Bug]: updating go deps broken with bzlmod #760

Closed jbedard closed 2 weeks ago

jbedard commented 1 month ago

What happened?

Crashes or really slow when updating go deps in bzlmod.

Version

Development (host) and target OS/architectures:

Output of bazel --version:

Version of the Aspect rules, or other relevant rules from your WORKSPACE or MODULE.bazel file:

Language(s) and/or frameworks involved:

How to reproduce

See https://aspect-build.slack.com/archives/C04281DTLH0/p1729081900853419

Any other information?

See fix in gazelle sh script: https://github.com/bazel-contrib/bazel-gazelle/blob/b160ccd46fb7c19a49530d08906165c73c343dd1/internal/gazelle.bash.in#L101-L106

r0bobo commented 1 month ago

I will try to create a PR next week if I find some time. Do you know how to deduce the -repo_config path of the top of your head?

r0bobo commented 1 month ago

I can also add that this is not a problem with bzlmod and rules_go when you use go mod vendor for all depedencies. It only manifests when we remove vendoring and use:

# MODULE.bazel
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
r0bobo commented 1 month ago

I will try to create a PR next week if I find some time. Do you know how to deduce the -repo_config path of the top of your head?

Hmm, this is more complicated than I first thought. Does aspect configure need to run bazel first to generate the gazelle~~go_deps~bazel_gazelle_go_repository_config/WORKSPACE repository that contains the go_repository(...) declarations? The WORKSPACE files looks something like that:

go_repository(
    name = "@gazelle~",
    importpath = "github.com/bazelbuild/bazel-gazelle",
    module_name = "gazelle",
)
go_repository(
    name = "@rules_go~",
    importpath = "github.com/bazelbuild/rules_go",
    module_name = "rules_go",
)
go_repository(
    name = "co_honnef_go_tools",
    importpath = "honnef.co/go/tools",
)
...
r0bobo commented 3 weeks ago

Here is a repo to reproduce the slow performance behavior. The results of gazelle vs aspect configure:

❯ time bzl configure
Updating BUILD files for go
2 BUILD files visited
0 BUILD files updated
bazelisk configure  18.23s user 3.18s system 140% cpu 15.257 total

❯ time bzl run gazelle
INFO: Analyzed target //:gazelle (0 packages loaded, 0 targets configured).
INFO: Found 1 target...
Target //:gazelle up-to-date:
  bazel-bin/gazelle-runner.bash
  bazel-bin/gazelle
INFO: Elapsed time: 0.073s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Running command line: bazel-bin/gazelle
bazelisk run gazelle  0.10s user 0.13s system 88% cpu 0.258 total
r0bobo commented 2 weeks ago

Hmm, is this really fixed? 🤔 I see the same behavior from latest main.

jbedard commented 2 weeks ago

It is fixed in the aspect private repo. If you're using the cli from this repo you'll have to wait till the change gets pushed here. Sorry I guess that's confusing when it gets closed from the private repo :/

r0bobo commented 2 weeks ago

Aha, I understand. I'm just glad to hear it's fixed. Thanks!

On Wed, 6 Nov 2024, 20:24 Jason Bedard, @.***> wrote:

It is fixed in the aspect private repo. If you're using the cli from this repo you'll have to wait till the change gets pushed here. Sorry I guess that's confusing when it gets closed from the private repo :/

— Reply to this email directly, view it on GitHub https://github.com/aspect-build/aspect-cli/issues/760#issuecomment-2460593019, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADM3WLVSJ74FVWZU6MBBMODZ7JUFHAVCNFSM6AAAAABQGW54IKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRQGU4TGMBRHE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jbedard commented 2 weeks ago

This will be in the next release which is currently publishing