Maison > développement back-end > Golang > le corps du texte

Comment réparer compilepkg : dépendance stricte manquante sur golang.org/x/sys/unix lors de la construction du projet Bazel ?

王林
Libérer: 2024-02-09 16:51:08
avant
1182 Les gens l'ont consulté

Comment réparer compilepkg : dépendance stricte manquante sur golang.org/x/sys/unix lors de la construction du projet Bazel ?

Dans cet article, l'éditeur PHP Strawberry vous présentera comment résoudre le problème de compilepkg, qui se produit lors de la construction du projet Bazel sans dépendance stricte de golang.org/x/sys/unix. Vous pouvez rencontrer ce problème lorsque vous utilisez Bazel pour créer un projet Go, car Bazel nécessite une dépendance stricte à l'égard du package golang.org/x/sys/unix pendant le processus de construction. Ensuite, nous vous fournirons des étapes détaillées pour résoudre ce problème afin de vous aider à mener à bien le processus de création de projet. Veuillez continuer à lire pour plus d'information.

Contenu de la question

J'essaie d'exécuter une version locale de ce référentiel sur mon PC. J'utilise Debian 12 et j'ai installé Bazel v6.4.0 et Go v1.21.5. Je ne connais pas très bien Go, et encore moins Bazel.

Lorsque j'exécute la commande suggérée dans les instructions d'installation pour construire le projet, c'est-à-dire bazel //..., j'obtiens l'erreur suivante :

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
Copier après la connexion

J'ai essayé d'ajouter ce qui suit au fichier WORKSPACE mais cela entraîne la même erreur

go_repository(
    name = "org_golang_x_sys",
    importpath = "github.com/golang/sys",
    commit = "13b15b780d9013988b1fb0e79e30b2528a877638",
)
Copier après la connexion

L'importation de golang.org/x/sys/unix à l'aide du processus d'importation Go habituel fonctionne bien ailleurs sur mon système, donc je pense que cela a quelque chose à voir avec la configuration de Bazel. Un expert Bazel peut-il m'aider à résoudre ce problème ? golang.org/x/sys/unix 在我系统的其他地方工作得很好,所以我认为这与 Bazel 配置有关。 Bazel 专家可以帮我解决这个问题吗?

解决方法

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

Solution de contournement

bazel run //:gazelle -- update-repos golang.org/x/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="285b515b685e1806191b0618"> [email protected]</a> 将以下行添加到我的 WORKSPACEIl s'avère que mon idée était correcte, mais je n'ai pas ajouté correctement le référentiel au fichier WORKSPACE.

🎜Exécutez 🎜 le fichier et construisez avec succès. 🎜
go_repository(
    name = "org_golang_x_sys",
    importpath = "golang.org/x/sys",
    sum = "h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=",
    version = "v0.13.0",
)
Copier après la connexion

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

source:stackoverflow.com
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!