Hey folks - I'm upgrading my `pants` project and a...
# general
f
Hey folks - I'm upgrading my
pants
project and am running into an issue introduced in the 2.18.x series. I have a
_scaffolding
directory that I use to generate new projects in my monorepo. Inside this directory, there are
BUILD
files, but they're templates, so
pants
should ignore them.
Copy code
_scaffolding
├── _cdk-common
│   └── Makefile
├── ecs_task
│   ├── template.toml
│   └── {{project_name}}
│       ├── BUILD
│       ├── Makefile -> ../../_cdk-common/Makefile
│       ├── README.md
│       └── src
└── generic
    ├── template.toml
    └── {{project_name}}
        ├── BUILD
        ├── Makefile -> ../../_cdk-common/Makefile
        ├── README.md
        └── src
Previously,
[GLOBAL].pants_ignore.add=["/_scaffolding/"]
seemed to do the trick to ignore these files. However, starting with Pants 2.18,
tailor
is not ignoring these files as before:
Copy code
> pants \
  --changed-since=origin/main \
  tailor --check
08:39:40.80 [INFO] Initializing scheduler...
08:39:43.07 [INFO] Scheduler initialized.
08:39:43.61 [ERROR] 1 Exception encountered:

Engine traceback:
  in `tailor` goal

IntrinsicError: Unmatched globs from `--changed-since`: ["_scaffolding/ecs_task/{{project_name}}/*", "_scaffolding/generic/{{project_name}}/*"]

Do the file(s) exist? If so, check if the file(s) are in your `.gitignore` or the global `pants_ignore` option, which may result in Pants not being able to see the file(s) even though they exist on disk. Refer to <https://www.pantsbuild.org/v2.19/docs/troubleshooting#pants-cannot-find-a-file-in-your-project>.
I've tried: •
[GLOBAL].build_ignore = ["_scaffolding/*"]
[tailor].ignore_paths = ["_scaffolding/*"]
But I can't get past the error. Any other ideas?
g
f
I tried that and it didn't work unfortunately
I've tried:
[GLOBAL].build_ignore = ["_scaffolding/*"]
[tailor].ignore_paths = ["_scaffolding/*"]
g
Ah, sorry. Misread your opening message.
👍 1
f
Good thought, though! I found that when reviewing slack
No prob 🙂
g
Does
pants tailor ::
actually do anything or is it only a problem in check mode?
And similarly, does removing
--changed-since=...
affect it?
f
Does
pants tailor ::
actually do anything or is it only a problem in check mode?
Copy code
pants \
  --changed-since=465e752909de27763465b7cfc9c8c14de4909641 \
  tailor
10:46:03.39 [ERROR] 1 Exception encountered:

Engine traceback:
  in `tailor` goal

IntrinsicError: Unmatched globs from `--changed-since`: ["_scaffolding/ecs_task/{{project_name}}/*", "_scaffolding/generic/{{project_name}}/*"]

Do the file(s) exist? If so, check if the file(s) are in your `.gitignore` or the global `pants_ignore` option, which may result in Pants not being able to see the file(s) even though they exist on disk. Refer to <https://www.pantsbuild.org/v2.19/docs/troubleshooting#pants-cannot-find-a-file-in-your-project>.
Looks like I'm hitting the error even without
--check
pants tailor ::
doesn't change anything
And similarly, does removing
--changed-since=...
affect it?
pants tailor --check ::
also doesn't change anything
I wonder if the weird
{{project_name}}
folders are tripping it up (it's an odd pattern used by the scaffolding tool)
Ah, nope, looks like not:
Copy code
pants \
  --changed-since=465e752909de27763465b7cfc9c8c14de4909641 \
  tailor
10:50:34.50 [ERROR] 1 Exception encountered:

Engine traceback:
  in `tailor` goal

IntrinsicError: Unmatched globs from `--changed-since`: ["_scaffolding/ecs_task/project_name/*", "_scaffolding/generic/project_name/*"]

Do the file(s) exist? If so, check if the file(s) are in your `.gitignore` or the global `pants_ignore` option, which may result in Pants not being able to see the file(s) even though they exist on disk. Refer to <https://www.pantsbuild.org/v2.19/docs/troubleshooting#pants-cannot-find-a-file-in-your-project>.
(changed
{{project_name}}
to
project_name
)
g
I'm digging through the code. I think
--changed-since
is to blame here, finding added files and asking Pants to do something with them but Pants then saying it doesn't know them.
f
That sounds like what I'm seeing. If I remove the
pants_ignore.add
, it starts to complain about invalid syntax in the
BUILD
file (which makes sense, since it's a template, not a real
BUILD
file)
g
I'm guessing if you remove the BUILD file it also works with --changed-since?
f
I removed the BUILD files:
Copy code
delete mode 100644 _scaffolding/ecs_task/{{project_name}}/BUILD
 delete mode 100644 _scaffolding/generic/{{project_name}}/BUILD
but still get the error
Copy code
pants \
  --changed-since=465e752909de27763465b7cfc9c8c14de4909641 \
  tailor
12:11:11.06 [INFO] Initializing scheduler...
12:11:13.37 [INFO] Scheduler initialized.
12:11:14.34 [ERROR] 1 Exception encountered:

Engine traceback:
  in `tailor` goal

IntrinsicError: Unmatched globs from `--changed-since`: ["_scaffolding/ecs_task/{{project_name}}/*", "_scaffolding/generic/{{project_name}}/*"]

Do the file(s) exist? If so, check if the file(s) are in your `.gitignore` or the global `pants_ignore` option, which may result in Pants not being able to see the file(s) even though they exist on disk. Refer to <https://www.pantsbuild.org/v2.19/docs/troubleshooting#pants-cannot-find-a-file-in-your-project>.
That might be, though, because the files did exist at the commit we're comparing?
g
Could be yeah, I started being able to repro when adding the files.
👍 1
I think something is weird in the interaction between
[global].build_ignore
and
[global].build_patterns
. I'm not sure how they're meant to interact, but if I rename the file to
BUILD.tmpl
and set
--build-patterns='-["BUILD.*"]'
it works.
f
🤔 hmm
g
Can you file an issue? I can fill in some details; but what is essentially happening is immensely dumb. Because your --pants-ignore removes all files in the directory, it fails to find any files in there that it could ignore. With
foobar/{foo.py,BUILD}
in my directory, it works as expected if I only ignore
foobar/foo.py
.
f
Yep, can do. It sounded like you had a reproducible example? (that'd save me a good deal of time)
g
All I've done is muck around in the Pants repo root, but sure. Fwiw, as a workaround: • Add a
DUMMY
file next to your BUILD file • After your scaffolding ignore regex, explicitly override to include the dummy file • In your build ignore, only mention the BUILD file
That should ensure that all globs see at least one file 🤷
f
Cool - I'll file an issue here in a few minutes. Thanks for your help!
g
No worries, thanks for the patience!
f
Thanks again!
@happy-kitchen-89482 fixed this (and a related issue, too!) - thank you!