https://pantsbuild.org/ logo
#general
Title
# general
h

high-energy-55500

05/24/2022, 10:11 AM
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

curved-television-6568

05/24/2022, 10:17 AM
Oh, maybe that option is not granular enough for your use case… ?
h

high-energy-55500

05/24/2022, 10:29 AM
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

bitter-ability-32190

05/24/2022, 10:32 AM
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

hundreds-father-404

05/24/2022, 12:10 PM
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

curved-television-6568

05/24/2022, 12:11 PM
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

hundreds-father-404

05/24/2022, 12:15 PM
What's the use case for that?
c

curved-television-6568

05/24/2022, 12:15 PM
not sure.. but from the OP:
i have a few
files
targets that I don’t care if they’re missing or not
b

bitter-ability-32190

05/24/2022, 12:24 PM
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

hundreds-father-404

05/24/2022, 12:31 PM
why not delete the targets?
b

bitter-ability-32190

05/24/2022, 12:44 PM
For people running the scripts that need the assets, they need the assets 😅
h

hundreds-father-404

05/24/2022, 12:50 PM
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

bitter-ability-32190

05/24/2022, 1:03 PM
But then why would the
sources
ever be empty? The assets either exist or they don't, right?
They are gitignored
h

hundreds-father-404

05/24/2022, 1:14 PM
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

bitter-ability-32190

05/24/2022, 1:14 PM
All users
h

hundreds-father-404

05/24/2022, 1:16 PM
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

bitter-ability-32190

05/24/2022, 1:16 PM
Yeah I haven't figured that out yet 🙂 Which is why I'm surfacing my use-case to add on 🙂
h

hundreds-father-404

05/24/2022, 1:24 PM
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

bitter-ability-32190

05/24/2022, 1:26 PM
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

high-energy-55500

05/24/2022, 5:38 PM
@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

hundreds-father-404

05/24/2022, 6:01 PM
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

high-energy-55500

05/24/2022, 8:17 PM
4 Views