sluongng / staticcheck-codegen

Run 'staticcheck' in Bazel with rules_go's nogo static analysis.
8 stars 2 forks source link

cycled dependency issue #3

Open fandw opened 2 years ago

fandw commented 2 years ago

I encountered a cycled dependency while trying to build:

ERROR: /home/dfan/.cache/bazel/_bazel_dfan/fed68e4fa5ba089266f54dd53bbfcf56/external/io_bazel_rules_nogo/BUILD.bazel:3:6: in alias rule @io_bazel_rules_nogo//:nogo: cycle in dependency graph: //go/src/.../inna/proofofconcept:proofofconcept @io_bazel_rules_go//:go_context_data .-> @io_bazel_rules_nogo//:nogo | //:nogo | @com_github_sluongng_staticcheck_codegen//_gen/qf1004:go_default_library | @com_github_sluongng_staticcheck_codegen//_gen/qf1004:qf1004 | @io_bazel_rules_go//:go_context_data `-- @io_bazel_rules_nogo//:nogo

my BUILD.bazel file in qf1004 looks normal to me:

load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library( name = "qf1004", srcs = ["analyzer.go"], importpath = "github.com/sluongng/staticcheck-codegen/_gen/qf1004", visibility = ["//visibility:public"], deps = ["@co_honnef_go_tools//quickfix"], )

alias( name = "go_default_library", actual = ":qf1004", visibility = ["//visibility:public"], )

I'm not really understanding why it would need to depend on nogo.

In addition: is v0.29.0 a hard requirement for rule_go? What's the reason that it has to be the latest?

sluongng commented 2 years ago

Hey Daiwei @fandw ,

I got your email regarding this issue as well.

My first question is, is v0.29.0 a hard requirement for rule_go? What's the reason that it has to be the latest?

There were a few changes needed in rules_go so that all checks in staticcheck can be fully enabled. You can refer to these PR for more details:

Second question is I encountered a cycled dependency while trying to build

Yes, this is a known issue in rules_go and bazel. I think it's because you have genquery used within the repo?

Here are the relevant issues on how Uber folks solved the problem:

Sort answer is: with the way most recent version of rules_go constructed nogo dependencies, genquery usage not gona be compatible. Instead, Uber folks rewrote their genquery usage to aspect instead.

Hope it helps.