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

Gomock missing go_default_library targets #3154

Closed
nickgooding opened this issue May 13, 2022 · 2 comments · Fixed by #3155
Closed

Gomock missing go_default_library targets #3154

nickgooding opened this issue May 13, 2022 · 2 comments · Fixed by #3155
Assignees

Comments

@nickgooding
Copy link
Contributor

nickgooding commented May 13, 2022

What version of rules_go are you using?

v0.32.0

What version of gazelle are you using?

v0.25.0

What version of Bazel are you using?

v5.1.1

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

Yes

What operating system and processor architecture are you using?

Mac OS 12.3, x86_64-apple-darwin21.1.0

Any other potentially useful information about your toolchain?

N/A

What did you do?

Tried to build go_* targets that depend on go_default_library targets in @com_github_golang_mock after upgrading to rules_go v0.32.0

What did you expect to see?

Build would work successfully

What did you see instead?

Builds failed with this error:

ERROR: <snip>/BUILD.bazel:3:11: no such target '@com_github_golang_mock//gomock:go_default_library': target 'go_default_library' not declared in package 'gomock' defined by <snip>/external/com_github_golang_mock/gomock/BUILD.bazel and referenced by '<snip>:go_default_library'

Workaround

Adding the following in our workspace and rerunning Gazelle resolved the issue (even though it isn't actually used in lieu of the dependency of rules_go)

     go_repository(
         name = "com_github_golang_mock",
         build_file_proto_mode = "disable",
+        # Workaround for bazelbuild/rules_go#3154
+        build_naming_convention = "import",
         importpath = "github.com/golang/mock",
         replace = "github.com/golang/mock",
         sum = "h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=",
         version = "v1.6.0",
     )
nickgooding added a commit to nickgooding/rules_go that referenced this issue May 13, 2022
Sets `go_naming_convention` to `import_alias` for gomock, as per the other
Go dependencies. This means users with `go_naming_convention` set to
`go_default_library` do not have to make adjustments to
Gazelle generated files or override the dependency.

Fixes bazelbuild#3154
@linzhp
Copy link
Contributor

linzhp commented May 16, 2022

How can I reproduce the issue?

@linzhp linzhp self-assigned this May 16, 2022
@nickgooding
Copy link
Contributor Author

To reproduce the issue, have a workspace using the go_default_library Gazelle naming convention and a go_library target created by Gazelle that depends on com_github_golang_mock. With rules_go v0.31.0, this would build fine, but upgrading to v0.32.0 breaks it. The fix is very trivial, as you can see in the linked PR.

This repo contains a very minimal reproduction: https://github.com/nickgooding/rules_go-3154-repro

linzhp pushed a commit that referenced this issue May 16, 2022
Sets `go_naming_convention` to `import_alias` for gomock, as per the other
Go dependencies. This means users with `go_naming_convention` set to
`go_default_library` do not have to make adjustments to
Gazelle generated files or override the dependency.

Fixes #3154
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

Successfully merging a pull request may close this issue.

2 participants