Bazel没有将BUILD文件添加到外部依赖项中。

huangapple go评论123阅读模式
英文:

Bazel not adding BUILD file to external dependency

问题

我有一个工作空间,在其中使用gazelle生成我的BUILD文件,但由于某种原因,com_github_ipfs_go_merkledag依赖项在解析其github.com/gogo/protobuf/gogoproto依赖项时导致构建失败。以下是设置和运行的内容。

工作空间:

  1. # 声明间接依赖项并初始化工具链。
  2. go_rules_dependencies()
  3. go_register_toolchains(version = "1.16")
  4. go_embed_data_dependencies()
  5. load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
  6. rules_proto_dependencies()
  7. rules_proto_toolchains()
  8. load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
  9. gazelle_dependencies()

命令:

  1. bazel run //:gazelle
  2. bazel run //:gazelle -- update-repos -from_file=go.mod
  3. bazel build //...

输出:

  1. ...
  2. no such package '@com_github_ipfs_go_merkledag//github.com/gogo/protobuf/gogoproto':
  3. BUILD file not found in directory 'github.com/gogo/protobuf/gogoproto' of external repository @com_github_ipfs_go_merkledag.
  4. Add a BUILD file to a directory to mark it as a package. and referenced by '@com_github_ipfs_go_merkledag//pb:merkledag_pb_go_proto'
  5. ...

不确定解决方法是什么?

英文:

I have a workspace where I use gazelle to generate my BUILD files and for some reason the com_github_ipfs_go_merkledag dependency is breaking the build when trying to resolve it's github.com/gogo/protobuf/gogoproto dependency. The setup and run is below.

Workspace:

  1. # Declare indirect dependencies and init toolchains.
  2. go_rules_dependencies()
  3. go_register_toolchains(version = "1.16")
  4. go_embed_data_dependencies()
  5. load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")
  6. rules_proto_dependencies()
  7. rules_proto_toolchains()
  8. load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
  9. gazelle_dependencies()

Commands:

  1. bazel run //:gazelle
  2. bazel run //:gazelle -- update-repos -from_file=go.mod
  3. bazel build //...

Output:

  1. ...
  2. no such package '@com_github_ipfs_go_merkledag//github.com/gogo/protobuf/gogoproto':
  3. BUILD file not found in directory 'github.com/gogo/protobuf/gogoproto' of external repository @com_github_ipfs_go_merkledag.
  4. Add a BUILD file to a directory to mark it as a package. and referenced by '@com_github_ipfs_go_merkledag//pb:merkledag_pb_go_proto'
  5. ...

Not sure what the solution for this is?

答案1

得分: 2

将构建指令添加到go_repository以忽略

  1. name = "com_github_ipfs_go_merkledag",
  2. importpath = "github.com/ipfs/go-merkledag",
  3. sum = "h1:ixNu/5MJSaT/Qs073T0/HsWKwnOoBgqSq1g+GaJIen0=",
  4. version = "v0.4.0",
  5. build_directives = [
  6. "gazelle:proto disable",
  7. ],
  8. )
英文:

Add build directives to the go_repository to ignore

  1. go_repository(
  2. name = "com_github_ipfs_go_merkledag",
  3. importpath = "github.com/ipfs/go-merkledag",
  4. sum = "h1:ixNu/5MJSaT/Qs073T0/HsWKwnOoBgqSq1g+GaJIen0=",
  5. version = "v0.4.0",
  6. build_directives = [
  7. "gazelle:proto disable",
  8. ],
  9. )

huangapple
  • 本文由 发表于 2021年8月14日 01:51:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/68776492.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定