I have an action_listener:
action_listener(
    name = "foo_listen",
    mnemonics = [
        "Foo", # Foo might usually take several minutes
    ],
    extra_actions = [
        "foo_action_pre", # Start some processing
        "foo_action_post", # Finish parts of processing that needs action output
    ],
)
In foo_action_pre, I set
out_templates=[
    "foo_action_pre_data",
],
in order to pass information to foo_action_post.
Now when I add $(location foo_action_pre_data) to the cmd of foo_action_post Bazel complains, that it is not a prereq.
No matter whether I add that to tools or data though, it never is detected as a prereq. How can I declare the correct dependency?
                        
You have to use
$(output foo_action_pre_data)instead of$(location foo_action_pre_data).See extra_action.cmd.