rules_go icon indicating copy to clipboard operation
rules_go copied to clipboard

go_default_library: no such attribute 'importpath_aliases' in 'go_library' rule

Open vijaypandey11 opened this issue 2 years ago • 1 comments

What version of rules_go are you using?

v0.18.10

What version of gazelle are you using?

v0.18.2

What version of Bazel are you using?

v0.21.0

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

Not sure as we can not upgrade the above versions to their latest ones due to high interdependency between components

What operating system and processor architecture are you using?

Linux amd64

Any other potentially useful information about your toolchain?

Go Lang version 1.13

What did you do?

There are two scenarios:

  • using go.mod and go.sum files to download olivere/elastic (we are using shell script to run below command)

    • bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=go_dependencies.bzl%go_dependencies -build_file_proto_mode=disable
    • Using the above command, the below go_repository tag is formed(generated) inside bazel file
      • go_repository( name = "com_github_olivere_elastic", build_file_proto_mode = "disable", importpath = "github.com/olivere/elastic/v7", sum = "h1:0JOSFolWtyIlcwoqSMKUjXMvUziq1wKDZN2mq3Sclys=", version = "v7.0.11", )
  • without using go.mod, we are writing go_repository in bazel file as below

    • go_repository( name = "com_github_olivere_elastic", importpath = "github.com/olivere/elastic/v7", sum = "h1:0JOSFolWtyIlcwoqSMKUjXMvUziq1wKDZN2mq3Sclys=", version = "v7.0.11", )

In both the cases, we are getting below error: go_default_library: no such attribute 'importpath_aliases' in 'go_library' rule

What did you expect to see?

No Errors

What did you see instead?

ERROR: /root/.cache/bazel/_bazel_root/b890523a0c1b37838b38eb29a5dcdce0/external/com_github_olivere_elastic/BUILD.bazel:3:1: @com_github_olivere_elastic//:go_default_library: no such attribute 'importpath_aliases' in 'go_library' rule 05:36:29 ERROR: /root/.cache/bazel/_bazel_root/b890523a0c1b37838b38eb29a5dcdce0/external/com_github_olivere_elastic/config/BUILD.bazel:3:1: @com_github_olivere_elastic//config:go_default_library: no such attribute 'importpath_aliases' in 'go_library' rule 05:36:29 ERROR: /root/.cache/bazel/_bazel_root/b890523a0c1b37838b38eb29a5dcdce0/external/com_github_olivere_elastic/uritemplates/BUILD.bazel:3:1: @com_github_olivere_elastic//uritemplates:go_default_library: no such attribute 'importpath_aliases' in 'go_library' rule 05:36:29 ERROR: /root/.cache/bazel/_bazel_root/b890523a0c1b37838b38eb29a5dcdce0/external/com_github_olivere_elastic/BUILD.bazel:3:1: Target '@com_github_olivere_elastic//:acknowledged_response.go' contains an error and its package is in error and referenced by '@com_github_olivere_elastic//:go_default_library' 05:36:29 ERROR: /root/.cache/bazel/_bazel_root/b890523a0c1b37838b38eb29a5dcdce0/external/com_github_olivere_elastic/BUILD.bazel:3:1: Target '@com_github_olivere_elastic//:backoff.go' contains an error and its package is in error and referenced by '@com_github_olivere_elastic//:go_default_library' 05:36:29 ERROR: /root/.cache/bazel/_bazel_root/b890523a0c1b37838b38eb29a5dcdce0/external/com_github_olivere_elastic/BUILD.bazel:3:1: Target '@com_github_olivere_elastic//:bulk.go' contains an error and its package is in error and referenced by '@com_github_olivere_elastic//:go_default_library' 05:36:29 ERROR: /root/.cache/bazel/_bazel_root/b890523a0c1b37838b38eb29a5dcdce0/external/com_github_olivere_elastic/BUILD.bazel:3:1: Target '@com_github_olivere_elastic//:bulk_delete_request.go' contains an error and its package is in error and referenced by '@com_github_olivere_elastic//:go_default_library'

vijaypandey11 avatar Mar 24 '22 12:03 vijaypandey11

You're using very old versions of Bazel, Gazelle, Go and rules_go. I don't believe any of them are even supported anymore really.

I'd recommend upgrading them all first.

The attribute does exist (see https://github.com/bazelbuild/rules_go/blob/d606ba2c123826f153bbd037cf46e80b5eb8dc3e/docs/go/core/rules.md#go_library-importpath_aliases). Make sure the versions of Gazelle and rules_go are compatible with each other. Failing that, maybe try cleaning the cache (bazel clean --expunge).

uhthomas avatar Mar 25 '22 09:03 uhthomas