bazel-contrib / rules_go

Go rules for Bazel
Apache License 2.0
1.39k stars 664 forks source link

nogo 1.18/1.19 #3230

Open loeffel-io opened 2 years ago

loeffel-io commented 2 years ago

What version of rules_go are you using?

v0.33.0

What version of gazelle are you using?

v0.26.0

What version of Bazel are you using?

v5.2.0

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

Y

What operating system and processor architecture are you using?

Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:37 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T6000

What did you do?

nogo is working with the current config and gov1.17.11:

{
  "shadow": {
    "exclude_files": {
      "external/.*": "Third party code"
    }
  },
  "unsafeptr": {
    "exclude_files": {
      "external/org_golang_x_sys/.*": "Third party code"
    }
  },
  "unreachable": {
    "exclude_files": {
      "external/org_golang_google_protobuf/.*": "Third party code"
    }
  },
  "copylocks": {
    "exclude_files": {
      "external/org_golang_google_protobuf/.*": "Third party code"
    }
  },
  "composites": {
    "exclude_files": {
      "external/org_golang_google_protobuf/.*": "Third party code",
      "external/com_github_bazelbuild_buildtools/.*": "Third party code"
    }
  }
}

switching to gov1.18.3 results in:

compilepkg: nogo: errors found by nogo during build-time code analysis:
analyzer "asmdecl" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "assign" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "atomicalign" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "bools" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "buildssa" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "buildtag" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "ctrlflow" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "deepequalerrors" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "errorsas" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "httpresponse" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "ifaceassert" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "loopclosure" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "lostcancel" failed: failed prerequisites: ctrlflow@google.golang.org/protobuf/internal/detrand
analyzer "nilfunc" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "nilness" failed: failed prerequisites: buildssa@google.golang.org/protobuf/internal/detrand
analyzer "pkgfact" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "printf" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "shadow" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "shift" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "sortslice" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "stdmethods" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "stringintconv" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "testinggoroutine" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "tests" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "unmarshal" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "unsafeptr" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "unusedresult" failed: analysis skipped due to type-checking error: external/org_golang_google_protobuf/internal/detrand/rand.go:13:2: could not import encoding/binary (cannot import "encoding/binary" (unknown iexport format version 2), export data is newer version - update tool)

is there any information about that? would like to use go1.18.x

Thanks

loeffel-io commented 2 years ago

fyi: commit df02d01fb37701ff826697271220f043b364d1c1 is also not working

sluongng commented 2 years ago

which version of org_golang_google_protobuf are you using?

loeffel-io commented 2 years ago
go_repository(
    name = "org_golang_google_protobuf",
    importpath = "google.golang.org/protobuf",
    sum = "h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=",
    version = "v1.28.0",
)
loeffel-io commented 2 years ago

But this belongs to all other packages too:

earth-service-example git:(main) ✗ b build //...
INFO: Analyzed 104 targets (0 packages loaded, 0 targets configured).
INFO: Found 104 targets...
ERROR: /private/var/tmp/_bazel_loeffel/4ddf5fe6752b149c847ee673897a36c2/external/org_golang_x_net/context/BUILD.bazel:3:11: GoCompilePkg external/org_golang_x_net/context/context.a failed: (Exit 1): builder failed: error executing command bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/go_sdk/builder compilepkg -sdk external/go_sdk -installsuffix darwin_arm64 -src external/org_golang_x_net/context/context.go -src ... (remaining 29 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
compilepkg: nogo: errors found by nogo during build-time code analysis:
analyzer "asmdecl" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "assign" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "atomicalign" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "bools" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "buildssa" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "buildtag" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "ctrlflow" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "deepequalerrors" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "errorsas" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "httpresponse" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "ifaceassert" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "loopclosure" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "lostcancel" failed: failed prerequisites: ctrlflow@golang.org/x/net/context
analyzer "nilfunc" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "nilness" failed: failed prerequisites: buildssa@golang.org/x/net/context
analyzer "pkgfact" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "printf" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "shadow" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "shift" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "sortslice" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "stdmethods" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "stringintconv" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "testinggoroutine" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "tests" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "unmarshal" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "unsafeptr" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "unusedresult" failed: analysis skipped due to type-checking error: external/org_golang_x_net/context/go17.go:11:2: could not import context (cannot import "context" (unknown iexport format version 2), export data is newer version - update tool)
INFO: Elapsed time: 0,295s, Critical Path: 0,17s
INFO: 11 processes: 10 internal, 1 darwin-sandbox.
FAILED: Build did NOT complete successfully
loeffel-io commented 2 years ago
http_archive(
    name = "io_bazel_rules_go",
    sha256 = "16e9fca53ed6bd4ff4ad76facc9b7b651a89db1689a2877d6fd7b82aa824e366",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip",
        "https://github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip",
    ],
)

http_archive(
    name = "bazel_gazelle",
    sha256 = "501deb3d5695ab658e82f6f6f549ba681ea3ca2a5fb7911154b5aa45596183fa",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.26.0/bazel-gazelle-v0.26.0.tar.gz",
        "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.26.0/bazel-gazelle-v0.26.0.tar.gz",
    ],
)

http_archive(
    name = "io_bazel_rules_docker",
    sha256 = "b1e80761a8a8243d03ebca8845e9cc1ba6c82ce7c5179ce2b295cd36f7e394bf",
    urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.25.0/rules_docker-v0.25.0.tar.gz"],
)

http_archive(
    name = "io_bazel_rules_k8s",
    sha256 = "ce5b9bc0926681e2e7f2147b49096f143e6cbc783e71bc1d4f36ca76b00e6f4a",
    strip_prefix = "rules_k8s-0.7",
    urls = ["https://github.com/bazelbuild/rules_k8s/archive/refs/tags/v0.7.tar.gz"],
)

http_archive(
    name = "rules_proto",
    sha256 = "e017528fd1c91c5a33f15493e3a398181a9e821a804eb7ff5acdd1d2d6c2b18d",
    strip_prefix = "rules_proto-4.0.0-3.20.0",
    urls = [
        "https://github.com/bazelbuild/rules_proto/archive/refs/tags/4.0.0-3.20.0.tar.gz",
    ],
)

# patch
http_archive(
    name = "com_google_protobuf",
    sha256 = "c29d8b4b79389463c546f98b15aa4391d4ed7ec459340c47bffe15db63eb9126",
    strip_prefix = "protobuf-3.21.3",
    url = "https://github.com/protocolbuffers/protobuf/archive/v3.21.3.tar.gz",
)

http_archive(
    name = "rules_proto_grpc",
    sha256 = "a0519dccb89582a403a585fbdcd927d36894d43b5d9e71f445221d221d7106fd",
    strip_prefix = "rules_proto_grpc-7ceb4ffaeaa9b3a4734bc7669b2a1c5aa65d9d73",
    urls = ["https://github.com/rules-proto-grpc/rules_proto_grpc/archive/7ceb4ffaeaa9b3a4734bc7669b2a1c5aa65d9d73.tar.gz"],
)
hxtk commented 2 years ago

I found this issue by googling as I was encountering the same issue trying to update to Go version 1.18.4 in the repository for a project I have that's unfortunately more than a bit of a mess.

https://github.com/hxtk/yggdrasil/tree/f80750ce6091eb88a914db0bb4ca5a83faf0740a

However, I've been unable to reproduce the error in a minimal format thus far. My initial suspicion was that my workspace is somehow broken and this is just a symptom.

loeffel-io commented 2 years ago

reproducible with:

WORKSPACE:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

http_archive(
    name = "io_bazel_rules_go",
    sha256 = "16e9fca53ed6bd4ff4ad76facc9b7b651a89db1689a2877d6fd7b82aa824e366",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip",
        "https://github.com/bazelbuild/rules_go/releases/download/v0.34.0/rules_go-v0.34.0.zip",
    ],
)

http_archive(
    name = "bazel_gazelle",
    sha256 = "501deb3d5695ab658e82f6f6f549ba681ea3ca2a5fb7911154b5aa45596183fa",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.26.0/bazel-gazelle-v0.26.0.tar.gz",
        "https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.26.0/bazel-gazelle-v0.26.0.tar.gz",
    ],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
load("//:repositories.bzl", "go_repositories")

# gazelle:repository_macro repositories.bzl%go_repositories
go_repositories()

go_rules_dependencies()

go_register_toolchains(
    "1.19",
    nogo = "@//:nogo",
)

gazelle_dependencies()

BUILD.bazel

load("@bazel_gazelle//:def.bzl", "gazelle")
load("@io_bazel_rules_go//go:def.bzl", "TOOLS_NOGO", "nogo")

# gazelle:prefix github.com/mindful-hq/spansql-query-builder
gazelle(name = "gazelle")

nogo(
    name = "nogo",
    config = ":nogo.json",
    visibility = ["//visibility:public"],
    deps = TOOLS_NOGO + [],
)

Output:

INFO: Analyzed 4 targets (0 packages loaded, 0 targets configured).
INFO: Found 3 targets and 1 test target...
ERROR: /private/var/tmp/_bazel_loeffel/0ee7f835c562cb606ba891ce059f7c6d/external/com_google_cloud_go/civil/BUILD.bazel:3:11: GoCompilePkg external/com_google_cloud_go/civil/civil.a failed: (Exit 1): builder failed: error executing command bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/go_sdk/builder compilepkg -sdk external/go_sdk -installsuffix darwin_arm64 -src external/com_google_cloud_go/civil/civil.go -embedroot '' ... (remaining 20 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
compilepkg: nogo: errors found by nogo during build-time code analysis:
analyzer "asmdecl" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "assign" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "atomicalign" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "bools" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "buildssa" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "buildtag" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "ctrlflow" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "deepequalerrors" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "errorsas" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "httpresponse" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "ifaceassert" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "loopclosure" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "lostcancel" failed: failed prerequisites: ctrlflow@cloud.google.com/go/civil
analyzer "nilfunc" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "nilness" failed: failed prerequisites: buildssa@cloud.google.com/go/civil
analyzer "pkgfact" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "printf" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "shadow" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "shift" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "sortslice" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "stdmethods" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "stringintconv" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "testinggoroutine" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "tests" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "unmarshal" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "unsafeptr" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "unusedresult" failed: analysis skipped due to type-checking error: external/com_google_cloud_go/civil/civil.go:25:2: could not import fmt (cannot import "fmt" (unknown iexport format version 2), export data is newer version - update tool)
ERROR: /private/var/tmp/_bazel_loeffel/0ee7f835c562cb606ba891ce059f7c6d/external/com_github_pmezard_go_difflib/difflib/BUILD.bazel:3:11: GoCompilePkg external/com_github_pmezard_go_difflib/difflib/difflib.a failed: (Exit 1): builder failed: error executing command bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/go_sdk/builder compilepkg -sdk external/go_sdk -installsuffix darwin_arm64 -src external/com_github_pmezard_go_difflib/difflib/difflib.go ... (remaining 22 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
compilepkg: nogo: errors found by nogo during build-time code analysis:
analyzer "asmdecl" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "assign" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "atomicalign" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "bools" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "buildssa" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "buildtag" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "ctrlflow" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "deepequalerrors" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "errorsas" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "httpresponse" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "ifaceassert" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "loopclosure" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "lostcancel" failed: failed prerequisites: ctrlflow@github.com/pmezard/go-difflib/difflib
analyzer "nilfunc" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "nilness" failed: failed prerequisites: buildssa@github.com/pmezard/go-difflib/difflib
analyzer "pkgfact" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "printf" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "shadow" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "shift" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "sortslice" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "stdmethods" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "stringintconv" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "testinggoroutine" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "tests" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "unmarshal" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "unsafeptr" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
analyzer "unusedresult" failed: analysis skipped due to type-checking error: external/com_github_pmezard_go_difflib/difflib/difflib.go:19:2: could not import bufio (cannot import "bufio" (unknown iexport format version 2), export data is newer version - update tool)
hxtk commented 2 years ago

In your example you reference two files: //:nogo.json and //:repositories.bzl; that do not appear to be included, and if I replace both of those files with no-ops (comment out the references to //:repositories.bzl and echo {} > nogo.json), everything seems to build.

tadeboro commented 2 years ago

I can replicate the same issue in many of our repos. The only reliable way of making things work for me is to force-require latest stable x/tools. If I put

replace golang.org/x/tools => golang.org/x/tools v0.1.12

into my go.mod file and then update gazelle repos, things work as expected.

I would be lying if I would say that I know why this fixes isses (I am not really a go dev, just a poor infra/CI/CD engineer tasked with keeping CI pipelines green after upgrade to go 1.18).

I hope this helps.

loeffel-io commented 2 years ago

I can replicate the same issue in many of our repos. The only reliable way of making things work for me is to force-require latest stable x/tools. If I put

replace golang.org/x/tools => golang.org/x/tools v0.1.12

into my go.mod file and then update gazelle repos, things work as expected.

I would be lying if I would say that I know why this fixes isses (I am not really a go dev, just a poor infra/CI/CD engineer tasked with keeping CI pipelines green after upgrade to go 1.18).

I hope this helps.

works! 🚀

hxtk commented 2 years ago

Works for me as well. It is certainly the case that nogo uses golang.org/x/tools:

https://github.com/bazelbuild/rules_go/blob/efc3212592320c1ab7f986c9a7882770ee06ad3b/go/tools/builders/nogo_main.go#L41-L43

It gets declared here, using a recent enough version that our builds would work if we were using it:

https://github.com/bazelbuild/rules_go/blob/ff928427828fb00a4cf1aacf1c378e820448102e/go/private/repositories.bzl#L64-L83

It appears the issue is that somewhere in our repositories we are overriding it with an older version, probably via some indirect dependency.

I'm not sure how rules_go could prevent this without potentially breaking other things. Perhaps the best available solution is just to document the error and root cause in the documentation for nogo.

tadeboro commented 2 years ago

Perhaps the best available solution is just to document the error and root cause in the documentation for nogo.

I also think this is the way to go. Just surfacing the information from the https://github.com/bazelbuild/rules_go/pull/3175 (the Updated dependencies section) would help a lot.

uhthomas commented 1 year ago

Can close?

https://github.com/bazelbuild/rules_go/pull/3356