bazelbuild / bazel

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

The `no-cache` tag / execution requirement is broken for aspects #10205

Open thundergolfer opened 4 years ago

thundergolfer commented 4 years ago

Description of the problem / feature request:

In an aspect implementation, I am adding the following execution_requirements to my run_shell action:

        execution_requirements = {
            "no-sandbox": "1",
            "no-cache": "1",
            "no-remote": "1",
        }

This should result I think in the aspect's action not being cached, but it is being cached. After a bazel clean my aspect's action is run again.

Using --execution_log_json_file to look at things more closely, I can see that with the above execution_requirements the cacheable: true and remoteable: true lines disappear from the action descriptions. Unfortunately as said above the actions are still cached.

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

Take the "Simple Example" from https://docs.bazel.build/versions/master/skylark/aspects.html

and modify it to add:

inputs = []
for src in ctx.rule.attr.srcs:
            for f in src.files:
                inputs.append(f)

ctx.actions.run_shell(
        outputs = [],
        inputs = inputs,
        command = "echo 'hello world' > ~/mytest.txt",
        use_default_shell_env = True,
        execution_requirements = {
            "no-sandbox": "1",
            "no-cache": "1",
            "no-remote": "1",
        }
    )

Run the aspect, then delete the ~/mytest.txt file and run the aspect again. The action will not re-run and ~/mytest.txt won't be recreated.

What operating system are you running Bazel on?

darwin

What's the output of bazel info release?

release 1.0.0

Have you found anything relevant by searching the web?

nkoroste commented 3 years ago

Any updates on this?

chenk008 commented 3 years ago

I encountered the same issue in Starlark function with local

luisabv commented 2 years ago

I also would like a solution for it.