aspect-build / aspect-cli

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

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

Open jbedard opened 1 week ago

jbedard commented 1 week 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 6 days 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 6 days 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 4 days 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",
)
...