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

Allow update-repos to find all transitive dependencies, not just those listed in go.mod #1585

Open
cgrindel opened this issue Jul 21, 2023 · 0 comments

Comments

@cgrindel
Copy link
Member

cgrindel commented Jul 21, 2023

What version of gazelle are you using?

0.31.1

What version of rules_go are you using?

0.40.1

What version of Bazel are you using?

6.2.1

Does this issue reproduce with the latest releases of all the above?

Yes.

What operating system and processor architecture are you using?

MacOS/x86_64

What did you do?

I want to build a Go package with an executable (e.g. github.com/ekalinin/github-markdown-toc.go). The dependencies for this package are defined in the main package of the executable. As a result, running go get github.com/ekalinin/github-markdown-toc.go in my repo does not populate my go.mod with the transitive dependencies for the package. It merely adds the github.com/ekalinin/github-markdown-toc.go. After running update-repos and //:gazelle (i.e. update build files), executing the build fails because the transitive dependencies for github.com/ekalinin/github-markdown-toc.go are not found.

Note: I am running with bzlmod enabled.

What did you expect to see?

With bzlmod enabled, I expected update-repos to resolve all of the transitive dependencies for my dependency, just like it does when generating the legacy go_deps.bzl.

What did you see instead?

See above.

Related Slack thread

cgrindel added a commit to cgrindel/bazel-starlib that referenced this issue Jul 21, 2023
Reworked the Go dependencies for this repository so that we do not need
to list the transitive dependencies in `MODULE.bazel`. Because
`github.com/ekalinin/github-markdown-toc.go` references its dependencies
in its `main` package, `go get ...` does not add the transitive
dependencies to `go.mod`. The bzlmod-aware `update-repos` does not find
the transitive dependencies. To fix this, we add direct dependency for
`github.com/ekalinin/github-markdown-toc.go` to this repo and use it in
`cmd/go_deps`.

Related to bazel-contrib/bazel-gazelle#1585.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant