Consider the following:
genrule(
name = "gen",
out = "out.txt",
cmd = "echo $(location :bin) > $OUT",
)
cxx_binary(
name = "bin",
srcs = ["main.cpp"],
)
Where the contents of main.cpp are irrelevant.
If RBE is enabled and :bin is built remotely or cached, it will not be materialized locally, so out.txt will point to a file that does not exist.
This can be simply reproduced by building :gen remotely, and it can be proved that this is an RBE-related materialization issue because buck2 build --local-only --no-remote-cache :gen has the expected behavior: bin is materialized locally.