Heim  >  Artikel  >  Backend-Entwicklung  >  So beheben Sie das Problem „compilepkg“: Fehlt beim Erstellen des Bazel-Projekts eine strikte Abhängigkeit von golang.org/x/sys/unix?

So beheben Sie das Problem „compilepkg“: Fehlt beim Erstellen des Bazel-Projekts eine strikte Abhängigkeit von golang.org/x/sys/unix?

王林
王林nach vorne
2024-02-09 16:51:081156Durchsuche

So beheben Sie das Problem „compilepkg“: Fehlt beim Erstellen des Bazel-Projekts eine strikte Abhängigkeit von golang.org/x/sys/unix?

In diesem Artikel stellt Ihnen der PHP-Editor Strawberry vor, wie Sie das Compilepkg-Problem beheben können, das beim Erstellen des Bazel-Projekts ohne strikte Abhängigkeit von golang.org/x/sys/unix auftritt. Dieses Problem kann auftreten, wenn Sie Bazel zum Erstellen eines Go-Projekts verwenden, da Bazel während des Erstellungsprozesses eine strikte Abhängigkeit vom Paket golang.org/x/sys/unix erfordert. Als Nächstes stellen wir Ihnen detaillierte Schritte zur Lösung dieses Problems vor, damit Sie den Projekterstellungsprozess erfolgreich abschließen können. Bitte lesen Sie weiter für weitere Informationen.

Frageninhalt

Ich versuche, eine lokale Version dieses Repositorys auf meinem PC auszuführen. Ich verwende Debian 12 und habe Bazel v6.4.0 und Go v1.21.5 installiert. Ich bin mit Go nicht sehr vertraut und mit Bazel noch weniger vertraut.

Wenn ich den in den Installationsanweisungen vorgeschlagenen Befehl ausführe, um das Projekt zu erstellen, d. h. bazel //..., erhalte ich die folgende Fehlermeldung:

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

Ich habe versucht, Folgendes zur WORKSPACE-Datei hinzuzufügen, aber es tritt der gleiche Fehler auf

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

Der Import von golang.org/x/sys/unix mit dem üblichen Go-Importvorgang funktioniert anderswo auf meinem System einwandfrei, daher denke ich, dass dies etwas mit der Bazel-Konfiguration zu tun hat. Kann mir ein Bazel-Experte bei der Lösung dieses Problems helfen? golang.org/x/sys/unix 在我系统的其他地方工作得很好,所以我认为这与 Bazel 配置有关。 Bazel 专家可以帮我解决这个问题吗?

解决方法

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

Problemumgehung

bazel run //:gazelle -- update-repos golang.org/x/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="285b515b685e1806191b0618"> [email protected]</a> 将以下行添加到我的 WORKSPACEEs stellte sich heraus, dass meine Idee richtig war, aber ich habe das Repository nicht korrekt zur Datei WORKSPACE hinzugefügt.

🎜Datei ausführen 🎜 und erfolgreich erstellen. 🎜
go_repository(
    name = "org_golang_x_sys",
    importpath = "golang.org/x/sys",
    sum = "h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=",
    version = "v0.13.0",
)

Das obige ist der detaillierte Inhalt vonSo beheben Sie das Problem „compilepkg“: Fehlt beim Erstellen des Bazel-Projekts eine strikte Abhängigkeit von golang.org/x/sys/unix?. Für weitere Informationen folgen Sie bitte anderen verwandten Artikeln auf der PHP chinesischen Website!

Stellungnahme:
Dieser Artikel ist reproduziert unter:stackoverflow.com. Bei Verstößen wenden Sie sich bitte an admin@php.cn löschen