Bazel build error -- BUILD file location issue

267 views
Skip to first unread message

A Bit of Help

unread,
Nov 2, 2023, 2:27:37 AM11/2/23
to bazel-discuss
source code: https://github.com/abitofhelp/abohapis.git

Hello,

I am spinning up on Bazel and have a project containing protos that I want to share with several applications.  I used Gazelle to create the BUILD files and to pull dependencies from go.mod.  However, when I tell Bazel to build all targets, it reports the following error.

```
(23:10:58) ERROR: /Users/mike/Go/src/github.com/abitofhelp/abohapis/proto/abitofhelp/api/blob/v5/BUILD.bazel:5:14: no such package 'abitofhelp/enum/v5': BUILD file not found in any of the following directories. Add a BUILD file to a directory to mark it as a package.
 - /Users/mike/Go/src/github.com/abitofhelp/abohapis/abitofhelp/enum/v5
and referenced by '//proto/abitofhelp/api/blob/v5:abitofhelp_api_blob_v5_proto'
```
However, the error says that a package 'abitofhelp/enum/v5" does not exist, when the proto directory and files do exist and pass proto linting.  The error says that I need to put a BUILD.bazel file in a directory path that does not exist.  The path where the BUILD and proto files exist is /Users/mike/Go/src/github.com/abitofhelp/abohapis/proto/abitofhelp/enum/v5

It seems the error message path is missing the "proto" that exists in the directory hierarchy.

I have been wrangling with this issue and googling, but to no avail.  I'd appreciate your help to figure out what is wrong.  

Thank you for your time and interest.
Mike

Filip Filmar

unread,
Nov 2, 2023, 12:19:26 PM11/2/23
to A Bit of Help, bazel-discuss
On Wed, Nov 1, 2023 at 11:27 PM 'A Bit of Help' via bazel-discuss <bazel-...@googlegroups.com> wrote:
I have been wrangling with this issue and googling, but to no avail.  I'd appreciate your help to figure out what is wrong.  


The `deps` refers to "//abitofhelp/enum/v5:v5_proto", while the closest package that I can see in your source would be "//proto/abitofhelp/enum/v5".
This should remove the specific issue that you asked about. However you will probably need more work for this to compile.

Example: the target "//proto/abitofhelp/enum/v5:v5_proto" does not exist in that package: https://github.com/abitofhelp/abohapis/blob/main/proto/abitofhelp/enum/v5/BUILD.bazel#L5 You have ":abitofhelp_enum_v5_proto" and others, but ":v5_proto" is nowhere to be found.

Hope this helps you on your way. In short, make sure that your build files and your labels actually exist.

F

David Turner

unread,
Nov 2, 2023, 12:20:29 PM11/2/23
to A Bit of Help, bazel-discuss
It looks like this file defines a target that depends on a target labelled as //abitofhelp/enum/v5:v5_proto while your workspace directory layout provides //proto/abitofhelp/enum/v5:v5_proto.

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/9fb98940-3caf-4aa5-a274-e7e57eeb2fa8n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages