返回顶部
首页 > 资讯 > 后端开发 > GO >如何修复compilepkg:构建Bazel项目时缺少对golang.org/x/sys/unix的严格依赖?
  • 761
分享到

如何修复compilepkg:构建Bazel项目时缺少对golang.org/x/sys/unix的严格依赖?

2024-02-09 16:02:58 761人浏览 独家记忆
摘要

PHP小编草莓在这篇文章中将为您介绍如何修复compilepkg的问题,该问题出现在构建Bazel项目时缺少对golang.org/x/sys/unix的严格依赖。当您在使用Bazel

PHP小编草莓在这篇文章中将为您介绍如何修复compilepkg的问题,该问题出现在构建Bazel项目时缺少对golang.org/x/sys/unix的严格依赖。当您在使用Bazel构建Go项目时,可能会遇到这个问题,因为Bazel在构建过程中要求严格依赖于golang.org/x/sys/unix包。接下来,我们将为您提供解决这个问题的详细步骤,以帮助您顺利完成项目的构建过程。请继续阅读以获取更多信息。

问题内容

我正在尝试在我的 PC 上运行此存储库的本地版本。我使用的是 Debian 12,并安装了 Bazel v6.4.0 和 Go v1.21.5。我对 Go 不太熟悉,对 Bazel 更不熟悉。

当我运行安装说明中建议的命令来构建项目时,即 bazel //...,出现以下错误:

DEBUG: /home/henry/.cache/bazel/_bazel_henry/cefbbfcdd1c1bdf63e873be5150774b3/external/bazel_gazelle/internal/go_repository.bzl:184:18: org_golang_google_grpc: gazelle: finding module path for import golang.org/x/sys/unix: exit status 1: go: finding module for package golang.org/x/sys/unix
go: found golang.org/x/sys/unix in golang.org/x/sys v0.15.0
found packages unix (affinity_linux.go) and main (mkasm.go) in /home/henry/.cache/bazel/_bazel_henry/cefbbfcdd1c1bdf63e873be5150774b3/external/bazel_gazelle_go_repository_cache/pkg/mod/golang.org/x/[email protected]/unix
gazelle: finding module path for import golang.org/x/sys/unix: exit status 1: go: finding module for package golang.org/x/sys/unix
go: found golang.org/x/sys/unix in golang.org/x/sys v0.15.0
found packages unix (affinity_linux.go) and main (mkasm.go) in /home/henry/.cache/bazel/_bazel_henry/cefbbfcdd1c1bdf63e873be5150774b3/external/bazel_gazelle_go_repository_cache/pkg/mod/golang.org/x/[email protected]/unix
gazelle: finding module path for import golang.org/x/sys/unix: exit status 1: go: finding module for package golang.org/x/sys/unix
go: found golang.org/x/sys/unix in golang.org/x/sys v0.15.0
found packages unix (affinity_linux.go) and main (mkasm.go) in /home/henry/.cache/bazel/_bazel_henry/cefbbfcdd1c1bdf63e873be5150774b3/external/bazel_gazelle_go_repository_cache/pkg/mod/golang.org/x/[email protected]/unix
gazelle: finding module path for import golang.org/x/sys/unix: exit status 1: go: finding module for package golang.org/x/sys/unix
go: found golang.org/x/sys/unix in golang.org/x/sys v0.15.0
found packages unix (affinity_linux.go) and main (mkasm.go) in /home/henry/.cache/bazel/_bazel_henry/cefbbfcdd1c1bdf63e873be5150774b3/external/bazel_gazelle_go_repository_cache/pkg/mod/golang.org/x/[email protected]/unix
gazelle: finding module path for import golang.org/x/sys/unix: exit status 1: go: finding module for package golang.org/x/sys/unix
go: found golang.org/x/sys/unix in golang.org/x/sys v0.15.0
found packages unix (affinity_linux.go) and main (mkasm.go) in /home/henry/.cache/bazel/_bazel_henry/cefbbfcdd1c1bdf63e873be5150774b3/external/bazel_gazelle_go_repository_cache/pkg/mod/golang.org/x/[email protected]/unix
gazelle: finding module path for import golang.org/x/sys/unix: exit status 1: go: finding module for package golang.org/x/sys/unix
go: found golang.org/x/sys/unix in golang.org/x/sys v0.15.0
found packages unix (affinity_linux.go) and main (mkasm.go) in /home/henry/.cache/bazel/_bazel_henry/cefbbfcdd1c1bdf63e873be5150774b3/external/bazel_gazelle_go_repository_cache/pkg/mod/golang.org/x/[email protected]/unix
gazelle: finding module path for import golang.org/x/sys/unix: exit status 1: go: finding module for package golang.org/x/sys/unix
go: found golang.org/x/sys/unix in golang.org/x/sys v0.15.0
found packages unix (affinity_linux.go) and main (mkasm.go) in /home/henry/.cache/bazel/_bazel_henry/cefbbfcdd1c1bdf63e873be5150774b3/external/bazel_gazelle_go_repository_cache/pkg/mod/golang.org/x/[email protected]/unix
gazelle: finding module path for import golang.org/x/sys/unix: exit status 1: go: finding module for package golang.org/x/sys/unix
go: found golang.org/x/sys/unix in golang.org/x/sys v0.15.0
found packages unix (affinity_linux.go) and main (mkasm.go) in /home/henry/.cache/bazel/_bazel_henry/cefbbfcdd1c1bdf63e873be5150774b3/external/bazel_gazelle_go_repository_cache/pkg/mod/golang.org/x/[email protected]/unix
gazelle: finding module path for import golang.org/x/sys/unix: exit status 1: go: finding module for package golang.org/x/sys/unix
go: found golang.org/x/sys/unix in golang.org/x/sys v0.15.0
found packages unix (affinity_linux.go) and main (mkasm.go) in /home/henry/.cache/bazel/_bazel_henry/cefbbfcdd1c1bdf63e873be5150774b3/external/bazel_gazelle_go_repository_cache/pkg/mod/golang.org/x/[email protected]/unix
gazelle: finding module path for import golang.org/x/sys/unix: exit status 1: go: finding module for package golang.org/x/sys/unix
go: found golang.org/x/sys/unix in golang.org/x/sys v0.15.0
found packages unix (affinity_linux.go) and main (mkasm.go) in /home/henry/.cache/bazel/_bazel_henry/cefbbfcdd1c1bdf63e873be5150774b3/external/bazel_gazelle_go_repository_cache/pkg/mod/golang.org/x/[email protected]/unix
gazelle: finding module path for import golang.org/x/sys/unix: exit status 1: go: finding module for package golang.org/x/sys/unix
go: found golang.org/x/sys/unix in golang.org/x/sys v0.15.0
found packages unix (affinity_linux.go) and main (mkasm.go) in /home/henry/.cache/bazel/_bazel_henry/cefbbfcdd1c1bdf63e873be5150774b3/external/bazel_gazelle_go_repository_cache/pkg/mod/golang.org/x/[email protected]/unix
gazelle: finding module path for import golang.org/x/sys/unix: exit status 1: go: finding module for package golang.org/x/sys/unix
go: found golang.org/x/sys/unix in golang.org/x/sys v0.15.0
found packages unix (affinity_linux.go) and main (mkasm.go) in /home/henry/.cache/bazel/_bazel_henry/cefbbfcdd1c1bdf63e873be5150774b3/external/bazel_gazelle_go_repository_cache/pkg/mod/golang.org/x/[email protected]/unix
INFO: Analyzed 131 targets (171 packages loaded, 1946 targets configured).
INFO: Found 131 targets...
ERROR: /home/henry/.cache/bazel/_bazel_henry/cefbbfcdd1c1bdf63e873be5150774b3/external/com_GitHub_sirupsen_logrus/BUILD.bazel:3:11: GoCompilePkg external/com_github_sirupsen_logrus/go_default_library.a failed: (Exit 1): builder failed: error executing command (from target @com_github_sirupsen_logrus//:go_default_library) bazel-out/k8-opt-exec-2B5CBBC6-ST-625e526ca8a8/bin/external/go_sdk/builder compilepkg -sdk external/go_sdk -installsuffix linux_amd64 -src external/com_github_sirupsen_logrus/alt_exit.go -src ... (remaining 45 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/henry/.cache/bazel/_bazel_henry/cefbbfcdd1c1bdf63e873be5150774b3/sandbox/linux-sandbox/183/execroot/__main__/external/com_github_sirupsen_logrus/terminal_check_unix.go: import of "golang.org/x/sys/unix"
No dependencies were provided.
Check that imports in Go sources match importpath attributes in deps.
INFO: Elapsed time: 12.435s, Critical Path: 0.96s
INFO: 31 processes: 12 internal, 19 linux-sandbox.
FAILED: Build did NOT complete successfully

我尝试将以下内容添加到 WORKSPACE 文件中,但会导致相同的错误

go_repository(
    name = "org_golang_x_sys",
    importpath = "github.com/golang/sys",
    commit = "13b15b780d9013988b1fb0e79e30b2528a877638",
)

使用通常的 Go 导入过程导入 golang.org/x/sys/unix 在我系统的其他地方工作得很好,所以我认为这与 Bazel 配置有关。 Bazel 专家可以帮我解决这个问题吗?

解决方法

事实证明我的思路是正确的,但没有将存储库正确添加到 WORKSPACE 文件中。

运行 bazel run //:gazelle -- update-repos golang.org/x/ [email protected] 将以下行添加到我的 WORKSPACE 文件中,并且构建成功。

go_repository(
    name = "org_golang_x_sys",
    importpath = "golang.org/x/sys",
    sum = "h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=",
    version = "v0.13.0",
)

以上就是如何修复compilepkg:构建Bazel项目时缺少对golang.org/x/sys/unix的严格依赖?的详细内容,更多请关注编程网其它相关文章!

您可能感兴趣的文档:

--结束END--

本文标题: 如何修复compilepkg:构建Bazel项目时缺少对golang.org/x/sys/unix的严格依赖?

本文链接: https://lsjlt.com/news/562695.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作