Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additions to extra-source-files do not trigger rebuild #10801

Closed
andreasabel opened this issue Feb 23, 2025 · 2 comments
Closed

Additions to extra-source-files do not trigger rebuild #10801

andreasabel opened this issue Feb 23, 2025 · 2 comments

Comments

@andreasabel
Copy link
Member

If you change a file listed in extra-source-files, cabal rebuilds the project, but not if you add a file there.

I discovered this when playing with the embedDir function of the file-embed package. It uses template haskell to quote into a Haskell source all files contained in a directory, so when you add a file to this directory, you want a rebuild.
I thought that listing all these files in extra-source-files would do the trick. When adding a new file to the directory, I would add it to extra-source-files, and cabal would be doing a rebuild.
But while cabal correctly triggers a rebuild if I modify any of the files in extra-source-files, it does not seem to care about additions to the list.

I first thought only Stack has this problem, but Cabal does so as well. For reference, here is the Stack companion issue:

To reproduce, play with this little project:
embed-datadir-0.1.tar.gz

  • do a cabal run
  • change data/README.md and again do a cabal run and observe that changes did propagate
  • add a file data/Bar.md, also to extra-source-files, and try a cabal run; observe that no rebuild takes place defying expectation
@mpilgrem
Copy link
Collaborator

I would characterise this experience slightly differently:

  • Cabal (and Stack) do rebuild when a new file is added to extra-source-files; but
  • in this use case (use of package file-embed) there is nothing in that to trigger the recompilation of a module that has already been built once (unlike when the content of an existing file changes, and file-embed's use of qAddDependentFile does its job, causing the relevant module to be recompiled).

For most users, having a rebuild also recompile everything (just in case) would likely be suboptimal.

@andreasabel
Copy link
Member Author

Ok, I guess then I was on a wild goose chase.

@andreasabel andreasabel closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants