bazel - Bazel 错误:构建中止:没有这样的包 '@org_golang_x_tools//go/gcexportdata'
问题描述
里面有一个golang demo project
D:\workspace\www\go_work\src\golang_learning
,里面有这些文件:
golang_learning
|__ go.mod
|__ main.go
|__ WORKSPACE
|__ BUILD.bazel
go.mod
module golang_learning
main.go
package main
import "fmt"
func main() {
fmt.Println("Hello,world")
}
WORKSPACE
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "io_bazel_rules_go",
urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.16.1/rules_go-0.16.1.tar.gz"],
sha256 = "f5127a8f911468cd0b2d7a141f17253db81177523e4429796e14d429f5444f5f",
)
http_archive(
name = "bazel_gazelle",
urls = ["https://github.com/bazelbuild/bazel-gazelle/releases/download/0.15.0/bazel-gazelle-0.15.0.tar.gz"],
sha256 = "6e875ab4b6bf64a38c352887760f21203ab054676d9c1b274963907e0768740d",
)
load("@io_bazel_rules_go//go:def.bzl", "go_rules_dependencies", "go_register_toolchains")
go_rules_dependencies()
go_register_toolchains()
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")
gazelle_dependencies()
BUILD.bazel
load("@bazel_gazelle//:def.bzl", "gazelle")
# gazelle:prefix github.com/example/project
gazelle(name = "gazelle")
当我运行时bazel run //:gazelle
,有一些错误,如下:
PS D:\workspace\www\go_work\src\golang_learning> bazel run //:gazelle
DEBUG: C:/users/dell/_bazel_dell/4tmnaczu/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: 'BAZEL_VC' is not set, start looking for the latest Visual C++ installed.
DEBUG: C:/users/dell/_bazel_dell/4tmnaczu/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: Looking for VS%VERSION%COMNTOOLS environment variables, eg. VS140COMNTOOLS
DEBUG: C:/users/dell/_bazel_dell/4tmnaczu/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: Looking for Visual C++ through registry
DEBUG: C:/users/dell/_bazel_dell/4tmnaczu/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: Looking for default Visual C++ installation directory
DEBUG: C:/users/dell/_bazel_dell/4tmnaczu/external/bazel_tools/tools/cpp/lib_cc_configure.bzl:115:5:
Auto-Configuration Warning: 'PROGRAMFILES(X86)' environment variable is not set, using 'C:\Program Files (x86)' as default
ERROR: Analysis of target '//:gazelle' failed; build aborted: no such package '@org_golang_x_tools//go/gcexportdata': java.io.IOException: thread interrupted
INFO: Elapsed time: 339.763s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (42 packages loaded)
FAILED: Build did NOT complete successfully (42 packages loaded)
我应该怎么办?
解决方案
您可以使用更新“update-repos”命令来引用外部存储库。这会将 go_repository(...) 调用附加到您的 WORKSPACE 文件中。
参考:https ://github.com/bazelbuild/bazel-gazelle#update-repos
推荐阅读
- visual-studio-code - Vscode - 预览状态机图失败
- java - 获取日期设置不正确
- tensorflow - 在运行 CNN 模型时获取
- javascript - 使用 Google 表单填充 Google 文档:当表单中的字段为空时出现标点符号
- netsuite - Netsuite 高级 PDF 错误:模板 merging.java.lang.ArithmeticException 期间出现异常:/ 为零
- reactjs - 为什么 useRef 值在它是整数时会动态更新,但在它是字符串时会存储先前的值?
- ios - SceneKit - 基于环境光或旋转的彩色材质
- javascript - Express.js 服务器未呈现静态 javascript 文件
- dependency-injection - 在 Hub 类之外调用 SignalR 函数
- excel - 将 VBA 应用于多个工作表?