nx: `implicitDependencies` dont work when `.gitignore` include the file
Current Behavior
I create custom executor(ts) and add the output file to project graph by implicitDependencies.
But it cant work when .gitignore include the output file, so cache never be broken.

Expected Behavior
I think files in implicitDependencies should always add to project graph even they are included in .gitignore.
Steps to Reproduce
This issue may not be prioritized if details are not provided to help us reproduce the issue.
Failure Logs
Environment
nx:12.17.1
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 13
- Comments: 37 (5 by maintainers)
Commits related to this issue
- chore(core): Fix cache busting for graphql clients See issue: https://github.com/nrwl/nx/issues/6821 NX devs say that .nxignore can override gitignored files for hashing, but we've been unable to ma... — committed to island-is/island.is by eirikurn 7 months ago
- fix(core): Fix schema-files cache busting (#12932) * fix(core): Fix schema-files cache busting * chore(core): Upgrade glob library * chore(core): Fix cache busting for graphql clients See issue: h... — committed to island-is/island.is by eirikurn 7 months ago
Can confirm it is very surprising in any build system for .gitignore to cause a declared dependency to be silently ignored.
Can you all try adding the following to your
.nxignorefile and see if the issue is resolved?This should negate the
.gitignoreand everything should work as expected but the file will still begitignoredJust bumped into this as well with an
.envfile defining some API URLs which are necessary during build-time webpack bundling.I managed to get
inputsto consider entries within.gitignoreby adding a compensating exclusionary entry in.nxignore.Do note, if the files you want included in the hash sit within a
.gitignored directory entry that is not followed by a/*, the files will not be included in the hash. Even if you have an exclusionary entry in.nxignorefor the file(s)!The following configuration ended up working for me:
.gitignore
.nxignore
project.json
quick answer to myself, nxignore fixed my problem
I have a workaround for this problem until NX decides to fix it:
tools/cache-file.jsnx.jsonfile as described below:Hi, are there any updates in this?
Our applications builds are also depending on files generated by external service, whose are ignored by git.
We were quite fine with manually clearing cache when those file changed, but now we starting to use Nx Cloud and this is something we really struggle with.
All of things mentioned above, we also tried specifying project inputs (https://nx.dev/configuration/projectjson#inputs-&-namedinputs), but without any success.
Or is there anyone who at least figured out a workaround?
Update, adding output of nx report.
After some further investigation, it looks like this behaviour isn’t caused by a quirk in NX, but rather with the underlying
ignorecrate used by the native file hasher.There’s been a related open issue for a few years: https://github.com/BurntSushi/ripgrep/issues/1050
@X4V1 Do you mean this solution?
@a777med wrote that this didn’t work for him. Do you have different output?
EDIT Solution with
.nxignorefile and using inside it e.g.!path/to/implicitDependency(that is git ignored) worked for me!Now I use the source file instead of the output file, but the truth is that cache depend on the output file, so there some question when I change the source file but forgot build output: The cache would be broken when run the task. If we build output that we forgot and re-run the task, the cache would be same as before.