Open huonw opened 7 months ago
Heya @lilatomic I think you might've added this new warning (thanks for improving diagnostics!). Could you describe the background for #20390? Did you find circumstances where the existing warning didn't appear?
The warning ought to resolve with an explicit dep. We make the call to explicitly_provided_deps.disambiguated
.
I added the links to the slack conversations in the original MR, I didn't find a GH issue.
OK, I think I found the problem:
ExplicitlyProvidedDependencies.disambiguated
checks (in order):
So pex_binary(name="with-ignore-only", entry_point="./example.py", dependencies=["!:src@tags=b"])
works.
I think it's a bug that adding the dependency that is already inferred changes the inference behaviour.
I think it's unexpected that adding an explicit dep does not resolve the ambiguity, although I'm not sure it's incorrect. I think we could change the logic so that we mark as disambiguated if the intersection of the ambiguous owners and the explicitly provided dependencies results in exactly 1 item.
I don't think adding desired dependency explicitly works to disambiguate python sources either, except that (like here) it also forces the dependency to be included (by being a hard link).
Also I'd expect "./example.py:src@tags=a"
to not work. The entrypoint is supposed to be a python entrypoint, (in PEX becoming --entry-point MODULE[:SYMBOL]
. I think putting a Pants target here would result in surprises. We'd have to then convert it into a module path somehow, and there are edge cases with that.
Describe the bug
In 2.20, we have a new warning for if the
entry_point
refers to a known file path that is ambiguous, such as if a file is owned by a parametrised target. This warning appears to be:The first warning is visible in 2.19 and earlier, while the second is new to 2.20.
Having diagnostics is good as silently failing to infer means the PEX doesn't contain the code people expect, but, unfortunately, it seems to be impossible silence the second one, by either disambiguating it properly, providing dependencies or just overruling the warning for the specific PEX (i.e. tell Pants "I know, it's fine"):
entry_point="example.py:src@tags=a
orentry_point="//:src@tags=a"
(as implied by the error message) result in an invalid entry pointAs a resolution:
Reproducer that sets up three variations of this sort of
pex_binary
and runs them (not just package, so that we see if we got a working PEX):Output of
pants run :ambiguous
(note the two warnings):Output of
pants run :with-target
:Output of
pants run :with-dips
:Pants version 2.20
OS
macOS
Additional info
I think the new "Pants cannot resolve the entrypoint" warning was added in #20390. Presumably it was added because the existing warning wasn't appearing in some cases?