bazelbuild/bazel

Error Message Could be Improved for `http_file`

Open

#16,375 建立於 2022年10月2日

在 GitHub 查看
 (8 留言) (0 反應) (0 負責人)Java (4,465 fork)batch import
P3bad error messaginggood first issuehelp wantedteam-ExternalDepstype: bug

倉庫指標

Star
 (25,384 star)
PR 合併指標
 (平均合併 22天 20小時) (30 天內合併 77 個 PR)

描述

Description of the issue

The error messages when referencing an http_file in the srcs section can be cryptic and could be improved to help the user fix the problem.

Repro

# WORKSPACE
http_file(
    name = "available_port_finder",
    downloaded_file_path = "AvailablePortFinder.java",
    urls = [
        "https://svn.apache.org/viewvc/camel/trunk/components/camel-test/src/main/java/org/apache/camel/test/AvailablePortFinder.java?revision=1232764&view=co",
    ],
)
# BUILD
java_library(
    name = "available_port_finder",
    srcs = [
        "@available_port_finder//:AvailablePortFinder.java",
    ],
)

Then run:

$ bazel build //:available_port_finder

From here, one gets this message:

ERROR: /usr/local/home/aryehh/Development/code/BUILD.bazel:11:13: no such package '@available_port_finder//': BUILD file not found in directory '' of external repository @available_port_finder. Add a BUILD file to a directory to mark it as a package. and referenced by '//:available_port_finder'
ERROR: Analysis of target '//:available_port_finder' failed; build aborted: Analysis failed
INFO: Elapsed time: 0.172s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (1 packages loaded, 0 targets configured)
FAILED: Build did NOT complete successfully (1 packages loaded, 0 targets configured)

The way to fix the issue is to put "@available_port_finder//file" in the srcs attribute of the java_library.

Expected Behavior

Bazel tells the user to reference file instead of the downloaded_file_path (name of the file)


Which operating system are you running Bazel on?

Debian Rodete

What is the output of bazel info release?

bazel 5.3.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

release 5.3.1

貢獻者指南