is there a way to disable these warnings for speci...
# general
h
is there a way to disable these warnings for specific missing file targets?
Copy code
[WARN] Unmatched globs from //:git-files's `sources` field: [".git/HEAD", ".git/refs/heads/**/*"]
i have a few
files
targets that I don’t care if they’re missing or not, so I don’t mind hiding the warning for them. I’d probably even say that I usually don’t care about missing
files
targets as opposed to missing
resources
targets.
c
Oh, maybe that option is not granular enough for your use case… ?
h
ah, yes, I think that works just fine 🙂 I was expecting it to be an option in the target itself, but this makes sense as well
b
I actually have a similar ish use case. I'm wondering if we should add a field. It feels weird, but now there's two of us!
@hundreds-father-404 @happy-kitchen-89482 thoughts?
h
there is a global option: https://www.pantsbuild.org/docs/reference-global#section-files-not-found-behavior We got rid of the
ignore
option because it was a really common gotcha people were making to have bad
sources=
and people were getting confused. We didn't think
ignore
was safe But maybe we should add it...? It's super trivial to add, only a question of judgment
c
I think globally
ignore
may be bad practice, at least, but perhaps a way to indicate per source field, that the globs are required/optional ?
h
What's the use case for that?
c
not sure.. but from the OP:
i have a few
files
targets that I don’t care if they’re missing or not
b
Same here. Only some devs care to run the code that wants the files there. Other devs don't. Not good practice IMO but I don't have a better solution 😄
h
why not delete the targets?
b
For people running the scripts that need the assets, they need the assets 😅
h
But then why would the
sources
ever be empty? The assets either exist or they don't, right?
btw @high-energy-55500 , that warning at the top is an actual issue! Pants ignores your top-level
.git
by default, so it won't see
.git/HEAD
See https://www.pantsbuild.org/docs/troubleshooting#pants-cannot-find-a-file-in-your-project
b
But then why would the
sources
ever be empty? The assets either exist or they don't, right?
They are gitignored
h
gitignored for everyone, or only some users like via
.git/info/excludes
? If they're gitignored, that sounds like the same case as Martim and I would expect that to be a bug
b
All users
h
So then how would this work?
For people running the scripts that need the assets, they need the assets
Pants doesn't think the assets exist
b
Yeah I haven't figured that out yet 🙂 Which is why I'm surfacing my use-case to add on 🙂
h
you probably want to re-include the files with
pants_ignore
so that Pants can find the files. https://www.pantsbuild.org/docs/troubleshooting#pants-cannot-find-a-file-in-your-project The annoying warning is legit, it's helping you out here. Ignoring it would mask a real issue
b
Well in this case, they also just might not exist. So: • Most people dont have on disk • Some people do have on disk but gitignored I need to look into why its this way, and maybe change it. But it's kinda like Martim's case, just slightly different
h
@hundreds-father-404 that’s a good point, which is why we added some
.git
files to our
pants.toml
file 😄
Copy code
pants_ignore.add = [
  "!.git/",
  ".git/FETCH_HEAD",
  ".git/index*",
  ".git/logs/**/*",
  ".git/objects/**/*",
  ".git/refs/remotes/**/*",
  ".git/refs/tags/**/*",
]
so we have 2 use cases: for
git-files
, these files are often not available in non-local environments, but that’s typically not a problem since they’re not needed in that scenario and we have a fallback for those situations. another use case is when we use pants to create an asset that is later used by another pants command. we don’t care about these files not existing because they will be created when we’re running that command, but we still need pants to be able to see the files
2
h
Makes sense! Could you please open a GitHub issue? This use case suggests to me that indeed it would be cool if this were per-target. Fallback plan is to allow the global option Or maybe we just do status quo, where you use
pants_ignore
. Hm
h