please
please copied to clipboard
Reference to non-existent named output should be an error
A reference to a non-existent rule produces an error in Please. However, a reference to a non-existent named output just silently succeeds with no output. I would think that referring to a non-existent named output should fail with a similar error.
For example, given this BUILD file in the root of a project.
text_file(name='hello', content='Hello')
export_file(
name='bad-rule-ref',
# Reference to non-existent rule, produces an error
src='//:hola'
)
export_file(
name='bad-named-output-ref',
# The hello rule doesn't have named outputs, so this should result in an error but doesn't
src='//:hello|foo'
)
I get this behavior:
bash-5.1$ plz build //:hello
Build finished; total time 60ms, incrementality 0.0%. Outputs:
//:hello:
plz-out/gen/hello
bash-5.1$ plz build //:bad-rule-ref
Build stopped after 50ms. 1 target failed:
//:hola
Target //:hola (referenced by //:bad-rule-ref) doesn't exist
bash-5.1$ plz build //:bad-named-output-ref
Build finished; total time 40ms, incrementality 100.0%. Outputs:
//:bad-named-output-ref:
bash-5.1$
Note, when I try to build //:bad-rule-ref
I get an error message, but when I build `//:bad-named-output-ref', it succeeds with the rule producing no output file. This can make a misspelling in a build file very hard to track down, since a misspelled named output won't produce any error at the actual source of the problem.
I had a crack at fixing this but it's quite a lot of work. It essentially requires a huge refactor of all the dependency resolution code. The annotated build labels are currently a concept of the build inputs, and are lost when we register dependencies to targets. I'll add this to the backlog, though we have some high priority work internally for the next quarter so might take a little time to get around to this.