Bazel错误:构建中止:没有这样的包'@ org_golang_x_tools // go / gcexportdata'

时间:2018-11-05 11:00:52

标签: bazel

其中有一个golang演示项目 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)

我该怎么办?

1 个答案:

答案 0 :(得分:0)

您可以使用update“ update-repos”命令来引用外部存储库。这会将go_repository(...)调用追加到您的WORKSPACE文件中。

参考:https://github.com/bazelbuild/bazel-gazelle#update-repos

相关问题