Build Failed file not opened

67 views
Skip to first unread message

ashwith chandra

unread,
Jun 6, 2024, 1:44:02 PMJun 6
to bazel-discuss
Iam getting the error with this. I specified location correctly.

BUILD.png
main.cpp.png

Filip Filmar

unread,
Jun 6, 2024, 1:54:17 PMJun 6
to ashwith chandra, bazel-discuss
On Thu, Jun 6, 2024 at 10:44 AM ashwith chandra <ashwithc...@gmail.com> wrote:
I specified location correctly.

No, you did not.  :)

`data = [ "data/*" ]` does not mean what you think it means. It does not mean "get me all files from the "data" dir. It means get me a file named "*" from the data dir.

Either specify the file name you need in full (I recommend this), or use `glob(...)`.

F

ashwith chandra

unread,
Jun 6, 2024, 2:00:38 PMJun 6
to bazel-discuss
Now i declared glob and getting different error my path itself is empty string
Screenshot 2024-06-06 232928.png

Filip Filmar

unread,
Jun 6, 2024, 2:03:50 PMJun 6
to ashwith chandra, bazel-discuss
On Thu, Jun 6, 2024 at 11:00 AM ashwith chandra <ashwithc...@gmail.com> wrote:
Now i declared glob and getting different error my path itself is empty string

The specified path in your screenshot is simply incorrect.

Would you mind sharing a link to your public git repo or some such, instead of screenshots? It will be easier to show the needed changes.

F

ashwith chandra

unread,
Jun 6, 2024, 2:09:18 PMJun 6
to bazel-discuss
yeah 5 mins
Message has been deleted

ashwith chandra

unread,
Jun 6, 2024, 2:21:11 PMJun 6
to bazel-discuss

ashwith chandra

unread,
Jun 7, 2024, 4:55:10 AMJun 7
to bazel-discuss
???

Filip Filmar

unread,
Jun 7, 2024, 1:22:35 PMJun 7
to ashwith chandra, bazel-discuss
On Fri, Jun 7, 2024 at 1:55 AM ashwith chandra <ashwithc...@gmail.com> wrote:
???

Note that help on this mailing list is on a best effort basis.

Your repo does not compile on Linux so I could not test it directly, and I didn't have the time to fix Linux compilation yesterday.

Your options are to (1) wait for me to find the time to fix linux compilation; (2) wait for someone else with a windows setup, or willing and able to fix linux and/or look into the issue separately; or (3) fix the linux compilation yourself. 

Once that's done we can look into the original issue.

(Long term, I recommend having a public git repo where you can publish your minimal examples for any issue you might come across while learning about bazel, and having an actions setup for it, to ensure it's kept in a healthy state.)

F

Filip Filmar

unread,
Jun 7, 2024, 8:56:13 PMJun 7
to ashwith chandra, bazel-discuss

Filip Filmar

unread,
Jun 7, 2024, 9:07:24 PMJun 7
to ashwith chandra, bazel-discuss
On Fri, Jun 7, 2024 at 5:55 PM Filip Filmar <fil...@gmail.com> wrote:

The docs at https://github.com/bazelbuild/bazel/blob/master/tools/cpp/runfiles/runfiles_src.h#L17 aren't really explaining in a self-contained way, but note that a "path" ("_main/example_bin/data/Roboto-Black.ttf") arg is not the same as "label string" ("//example_bin/data:Robot-Black.ttf").
And `Rlocation` requires a **path** relative to the runfiles directory.

Also note that the file path includes the repository name, which in the case of unnamed repositories is `_main`. Now, that's not documented in the docs for `Rlocation`, but follows from the ability to refer to runfiles that come from external repos.

I am not sure I would recommend using Rlocation this way, since things may get messed up if this repo is being used as an external repo of another project. Perhaps some of the bazel folks could chime in and explain the intention here.

There is a much easier way to get at the rlocation of this file, which is to do something like this:

```
cc_binary(
  name = "example_bin",
  ...
  args = [
    "$(location //example_bin/data:Roboto-Black.ttf)",
  ]
  data = [
    "//example_bin/data:Roboto-Black.ttf",
  ],
```
This gives you the path of the file in `argv[1]` once example runs, which isn't very elegant but removes the need for the `runfiles` library.

I also fixed the `glob(...)` call.

In general I recommend scrutinizing the documentation a bit more closely. There's plenty of undocumented tidbits as it is now, but what is documented is usually very important. It's all part of a learning process.

HTH,
F

Reply all
Reply to author
Forward
0 new messages