bazelbuild / bazel

a fast, scalable, multi-language and extensible build system
https://bazel.build
Apache License 2.0
23.23k stars 4.08k forks source link

[GO] bazel build fails but go build works fine #15855

Closed cyyber closed 2 years ago

cyyber commented 2 years ago

Description of the bug:

bazel build //cmd/zond:zond

The above command gives following error

Extracting Bazel installation...
Starting local Bazel server and connecting to it...
ERROR: /home/cyyber/.cache/bazel/_bazel_cyyber/3a49417b1dd1f87823292d1011bf771b/external/com_github_libp2p_go_libp2p_core/sec/insecure/pb/BUILD.bazel:12:17: no such package '@com_github_libp2p_go_libp2p_core//github.com/libp2p/go-libp2p-core/crypto/pb': BUILD file not found in directory 'github.com/libp2p/go-libp2p-core/crypto/pb' of external repository @com_github_libp2p_go_libp2p_core. Add a BUILD file to a directory to mark it as a package. and referenced by '@com_github_libp2p_go_libp2p_core//sec/insecure/pb:plaintext_pb_go_proto'
ERROR: Analysis of target '//cmd/zond:zond' failed; build aborted: no such package '@com_github_libp2p_go_libp2p_core//github.com/libp2p/go-libp2p-core/crypto/pb': BUILD file not found in directory 'github.com/libp2p/go-libp2p-core/crypto/pb' of external repository @com_github_libp2p_go_libp2p_core. Add a BUILD file to a directory to mark it as a package.
INFO: Elapsed time: 87.212s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (246 packages loaded, 10458 targets configured)
    Fetching @org_golang_x_net; fetching
    Fetching @com_github_multiformats_go_multistream; fetching
    Fetching @com_github_multiformats_go_base32; fetching
    Fetching @in_gopkg_yaml_v2; fetching
    Fetching @org_uber_go_multierr; fetching
    Fetching @org_uber_go_zap; fetching
    Fetching @com_github_opentracing_opentracing_go; fetching
    Fetching @com_github_ipfs_go_log_v2; fetching ... (14 fetches)

However, the project builds itself without any issue if I use go build. The following works perfectly fine.

go build ./cmd/zond

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

git clone https://github.com/theQRL/zond
cd zond
bazel build //cmd/zond:zond

Which operating system are you running Bazel on?

Ubuntu 21.10

What is the output of bazel info release?

release 5.2.0

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

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

I checked /home/cyyber/.cache/bazel/_bazel_cyyber/3a49417b1dd1f87823292d1011bf771b/external/com_github_libp2p_go_libp2p_core/crypto/pb/ and the BUILD.bazel exists there, which is automatically generated by bazel.

Wyverald commented 2 years ago

The error message says "no such package '@com_github_libp2p_go_libp2p_core//github.com/libp2p/go-libp2p-core/crypto/pb'"; so you should check /home/cyyber/.cache/bazel/_bazel_cyyber/3a49417b1dd1f87823292d1011bf771b/external/com_github_libp2p_go_libp2p_core/github.com/libp2p/go-libp2p-core/crypto/pb/ for a BUILD file.

Anyway, this is most likely an issue with a wrong configuration of Gazelle, not a bug within Bazel. Please prefer to use the other communication channels for user support (bazel-discuss@googlegroups.com, https://slack.bazel.build, etc).

cyyber commented 2 years ago

The error message says "no such package '@com_github_libp2p_go_libp2p_core//github.com/libp2p/go-libp2p-core/crypto/pb'"; so you should check /home/cyyber/.cache/bazel/_bazel_cyyber/3a49417b1dd1f87823292d1011bf771b/external/com_github_libp2p_go_libp2p_core/github.com/libp2p/go-libp2p-core/crypto/pb/ for a BUILD file.

Anyway, this is most likely an issue with a wrong configuration of Gazelle, not a bug within Bazel. Please prefer to use the other communication channels for user support (bazel-discuss@googlegroups.com, https://slack.bazel.build, etc).

Already checked the above and mentioned the same under the question "Any other information, logs, or outputs that you want to share?"