rough-vase-83553
10/19/2022, 7:27 PMfiles(name = "all-the-files", sources = ["**"])
target to the repo root (don't ask me why simple smile). I'm guessing it's because we have some paths in the repository that contain asterisk (don't ask me why simple smile).
InvalidFieldException: The 'source' field in target //some/project/data/[*]/_SUCCESS:../../../../../all-the-files should not include `*` globs, but was set to some/project/data/[*]/_SUCCESS. Instead, use a literal file path (relative to the BUILD file).
The actual path is some/project/data/*/_SUCCESS
.rough-vase-83553
10/19/2022, 7:28 PMhundreds-father-404
10/19/2022, 7:30 PM[GLOBAL]
pants_ignore.add = ["some/project/data/*"]
I'm not surprised that Pants is upset with a file path with *
embedded in itrough-vase-83553
10/19/2022, 7:31 PMhundreds-father-404
10/19/2022, 7:32 PM*
in a file path?rough-vase-83553
10/19/2022, 7:33 PMhundreds-father-404
10/19/2022, 7:47 PM*
to work. Maybe something like escaping it. (We still want to error generally for *
because it's a core assumption that a file
target respond to exactly 1 file)
This is the error you're hitting:
https://github.com/pantsbuild/pants/blob/08410e5b94d3e3aa86b2538ee1991d964e27e72c/src/python/pants/engine/target.py#L2184-L2193rough-vase-83553
10/19/2022, 8:55 PMrough-vase-83553
10/19/2022, 8:56 PMrough-vase-83553
10/19/2022, 8:58 PMhundreds-father-404
10/19/2022, 9:01 PMOh I see. This is kind of a fail-fast to prevent accidental use of globs where paths are requiredExactly
Not too familiar with the architecture but would it be possible to check whether the file actually exists before making that assertionYeah, although there's more complexity here that the Rust engine will interpret
*
as a glob to match everything in that directory. Which is not the semantics you're looking for here -- you want *
to be interpreted as a literal character
Which is where I think escaping is relevant, figuring out how you can escape *
so that the engine treats it as a literal and not a globrough-vase-83553
10/19/2022, 9:04 PM\
escape is what you'd use in a glob engine. At least based on the fact echo **/\*/**
works as I'd expect on my shell.hundreds-father-404
10/19/2022, 9:07 PM./pants count-loc '<path>'
, where the ''
is to avoid shell escaping from happening. That will have the Rust engine's glob semantics kick in. Maybe set up something like this:
dir/
dir/a.txt
dir/b.txt
dir/*/
dir/*/a.txt
dir/*/b.txt
experiment with how quoting gets different resultshundreds-father-404
10/19/2022, 9:08 PM*
, then a patch would be welcomed to update https://github.com/pantsbuild/pants/blob/08410e5b94d3e3aa86b2538ee1991d964e27e72c/src/python/pants/engine/target.py#L2184-L2193 to have a more advanced string check, like banning *
except for the allowlisted value of \*
or whatever it isrough-vase-83553
10/19/2022, 9:10 PMfile(source="my/asterisk/\*/path")
instead of file(source="my/asterisk/*/path")
?hundreds-father-404
10/19/2022, 9:11 PMrough-vase-83553
10/19/2022, 9:11 PMfiles
would expand out globs into the escaped paths rather than the literal result of the glob expansionrough-vase-83553
10/19/2022, 9:12 PMhundreds-father-404
10/19/2022, 9:12 PMsome/project/data/[*]/_SUCCESS
hundreds-father-404
10/19/2022, 9:12 PM[]
in the actual file path?rough-vase-83553
10/19/2022, 9:13 PM\