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

gazelle resolve directives not working #1695

Open
VhalPurohit opened this issue Dec 21, 2023 · 0 comments
Open

gazelle resolve directives not working #1695

VhalPurohit opened this issue Dec 21, 2023 · 0 comments

Comments

@VhalPurohit
Copy link

VhalPurohit commented Dec 21, 2023

What version of gazelle are you using?

0.35.0 (bazel-gazelle)

What version of rules_go are you using?

0.44.0

What version of Bazel are you using?

6.4.0

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

Yes (currently using latest versions).

What operating system and processor architecture are you using?

Ubuntu 20.04, x86_64

What did you do?

Created a minimalistic bazel repo (https://github.com/VhalPurohit/gazelle-go-bug/tree/master) for a single main.go file that imports "cloud.google.com/go/storage"
its build rule has deps = ["@com_google_cloud_go//storage"] with a directive # gazelle:resolve go google.golang.org/genproto/googleapis/iam/v1 @org_golang_google_genproto//googleapis/iam/v1 and the build has a go_repository rule defined as such

go_repository(
        name = "com_google_cloud_go",
        build_file_proto_mode = "disable_global",
        build_directives = [
                "gazelle:resolve go google.golang.org/genproto/googleapis/iam/v1 @org_golang_google_genproto//googleapis/iam/v1",  # keep
            ],
        importpath = "cloud.google.com/go",
        strip_prefix = "google-cloud-go-storage-v1.36.0",
        build_file_generation = "on",
        urls = ["https://github.com/googleapis/google-cloud-go/archive/storage/v1.36.0.zip"],
    )

this repository rule by itself doesn't work so I kept adding go_repositories that @com_google_cloud_go depends on unitl the missing strict dependencies error that I couldn't get around

What did you expect to see?

bazel build t2:main succeeds (there are explicit gazelle resolve directives both in the go_repository rule and the BUILD file to prevent the missing strict deps error)

What did you see instead?

❯ bazel build t2:main
Starting local Bazel server and connecting to it...
DEBUG: /home/bazel/.cache/bazel/_bazel_bazel/fd6cc03cf1b89c041f6c1d0c8a59d607/external/io_bazel_rules_go/go/private/actions/link.bzl:58:18: Multiple copies of github.com/googleapis/gax-go/v2 passed to the linker. Ignoring bazel-out/k8-fastbuild/bin/external/com_github_googleapis_gax_go_v2/gax-go.a in favor of bazel-out/k8-fastbuild/bin/external/com_github_googleapis_gax_go/v2/gax-go.a
INFO: Analyzed target //t2:main (267 packages loaded, 11758 targets configured).
INFO: Found 1 target...
ERROR: /home/bazel/.cache/bazel/_bazel_bazel/fd6cc03cf1b89c041f6c1d0c8a59d607/external/com_google_cloud_go/iam/BUILD.bazel:3:11: GoCompilePkg external/com_google_cloud_go/iam/iam.a failed: (Exit 1): builder failed: error executing command (from target @com_google_cloud_go//iam:iam) bazel-out/k8-opt-exec-2B5CBBC6/bin/external/go_sdk/builder_reset/builder compilepkg -sdk external/go_sdk -installsuffix linux_amd64 -src external/com_google_cloud_go/iam/iam.go -embedroot '' -embedroot ... (remaining 25 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
compilepkg: missing strict dependencies:
/home/bazel/.cache/bazel/_bazel_bazel/fd6cc03cf1b89c041f6c1d0c8a59d607/sandbox/linux-sandbox/426/execroot/main/external/com_google_cloud_go/iam/iam.go: import of "google.golang.org/genproto/googleapis/iam/v1"
No dependencies were provided.

Check that imports in Go sources match importpath attributes in deps.
Target //t2:main failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 115.067s, Critical Path: 61.41s
INFO: 445 processes: 21 internal, 424 linux-sandbox.
FAILED: Build did NOT complete successfully

Comments

The import that causes the failing strict dep is a protobuf import pb "google.golang.org/genproto/googleapis/iam/v1" in com_google_cloud_go/iam/iam.go ; so I tried the go_repository rule with all of

  1. build_file_proto_mode = "disable_global"
  2. build_file_proto_mode = "disable"
  3. build_file_proto_mode = "default"
  4. removing the build_file_proto_mode attribute altogether.

But all of them lead to the same error.
It seems like the build directives are not working, but I don't really know what's going on to be fully honest. Please help.

@VhalPurohit VhalPurohit changed the title compilepkg: missing strict dependencies for com_google_cloud_go//storage gazelle resolve directives not working Jan 2, 2024
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