gpt4 book ai didi

visual-studio-code - 检索 Bazel 构建目标的 VSCode 问题

转载 作者:行者123 更新时间:2023-12-04 08:56:42 25 4
gpt4 key购买 nike

我无法让 VSCode 加载 Java 项目的构建目标。我收到的错误消息如下:

Command failed: bazel --output_base=/var/folders/cj/1fv063dx1772zbpnfpzvj_c00000gn/T/5b71fd39758e7fd8e710c281fbbdda92 query ...:* --output=package Loading: 0 packages loaded ERROR: error loading package 'bazel-test/external/rules_jvm_external': cannot load '//:private/versions.bzl': no such file Loading: 12 packages loaded currently loading: bazel-test/external/local_config_cc ... (6 packages) Loading: 12 packages loaded currently loading: bazel-test/external/local_config_cc ... (6 packages)

我的WORKSPACE文件如下:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_rules_docker",
sha256 = "4521794f0fba2e20f3bf15846ab5e01d5332e587e9ce81629c7f96c793bb7036",
strip_prefix = "rules_docker-0.14.4",
urls = ["https://github.com/bazelbuild/rules_docker/releases/download/v0.14.4/rules_docker-v0.14.4.tar.gz"],
)

load(
"@io_bazel_rules_docker//repositories:repositories.bzl",
container_repositories = "repositories",
)
container_repositories()

load("@io_bazel_rules_docker//repositories:deps.bzl", container_deps = "deps")

container_deps()

load("@io_bazel_rules_docker//repositories:pip_repositories.bzl", "pip_deps")

pip_deps()

load(
"@io_bazel_rules_docker//java:image.bzl",
_java_image_repos = "repositories",
)

_java_image_repos()

load(
"@io_bazel_rules_docker//container:container.bzl",
"container_pull",
)

container_pull(
name = "openjdk11_slim",
registry = "index.docker.io",
repository = "library/openjdk",
tag = "11-slim"
)

RULES_JVM_EXTERNAL_TAG = "3.3"
RULES_JVM_EXTERNAL_SHA = "d85951a92c0908c80bd8551002d66cb23c3434409c814179c0ff026b53544dab"

http_archive(
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA,
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)

load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
artifacts = [
# Accessed as dependency: @maven://io_vertx_vertx_core
"io.vertx:vertx-core:3.9.2",
# Accessed as dependency: @maven://io_vertx_vertx_web
"io.vertx:vertx-web:3.9.2",
# Accessed as dependency: @maven://io_vertx_vertx_rx_java2
"io.vertx:vertx-rx-java2:3.9.2",
],
repositories = [
"https://repo1.maven.org/maven2",
]
)

我没有发现我的 WORKSPACE 文件有任何明显的错误,所以我很想假设问题出在 VSCode 或我的外部依赖项之一的 BUILD 文件中。除此之外,该项目包含一个 Hello.java 及其附带的 java_binary 规则。如果我对所有包运行相同的查询,我会得到以下结果:

% bazel query ...:\* --output=package          

src/main/java
Loading: 0 packages loaded

换句话说,没有错误。我有什么想法可以尝试调试或解决这个问题吗?我刚刚在笔记本电脑上安装了所有东西,所以软件版本是:

Bazel version: 3.5.0
VSCode versio: 1.48.2

最佳答案

comment 之后忽略方便的符号链接(symbolic link)为我解决了这个问题:

echo bazel-`basename ${PWD}` >> .bazelignore

关于visual-studio-code - 检索 Bazel 构建目标的 VSCode 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63788121/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com