如何修复compilepkg:构建Bazel项目时缺少对golang.org/x/sys/unix的严格依赖?
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登录后复制