-
Notifications
You must be signed in to change notification settings - Fork 842
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
Dirtiness checking triggers unnecessary reinstalls WAS: stack build unnecessarily reinstalls packages from github #838
Comments
This isn't related to the package being a dependency from github. I made a local clone of HStringTemplate and changed the stack.yaml to use
and the same thing happened. The reason it's happening is that, because of the way we detect TemplateHaskell dependent files, it sees them as new files in the second build and so runs the build again. Fixing that would introduce a race condition, and we'd rather have occasional redundant builds than a race condition. |
(it's not obvious where the TH dependency is introduced, but |
Perhaps that file should be special cased and not trigger dirtiness. The On Mon, Aug 24, 2015, 12:58 AM Emanuel Borsboom [email protected]
|
I am disappointed that you are closing this issue. It's not very reassuring having a build system that claims to be done but on the next call realises that it's it has still work to do. The whole point of having a build system is for tracking dependencies and not having to rebuild everything. I don't really mind how often stack builds stuff internally - but I want it to end in a clean state and correctly detect if a rebuild is needed. If you really need to build packages twice then it should be done in the the one 'stack build' call so that this call can end in a clean state. |
In this case, the second build truly is redundant. The first build did build all the files, and along the way it discovered that some TemplateHaskell code called So for a case like this, we could run another build automatically right after the first, but there wouldn't be much point. It would definitely make the first build take longer for no reason, whereas by being "lazy" there's a good chance something else changed next time you build anyway, so we're avoiding more redundant building than necessary. Now, if you're changing source files during the build, you of course can't be guaranteed that the build will pick up your changes while it's building, but that's hardly unique to TH dependencies. GHC doesn't go back and check for changed source files during a build and then rebuild them either. I don't know of any build system that does. But our choices here mean the next build will definitely pick up on the changes you made during the first. If you do want it to handle files that change during the build, the |
Is it common for that file to be used from TH code? I don't recall noticing it before, and I haven't actually found where In this particular case, the TH also adds a dependency for |
After some more thought: with a multi-package project, doing the second build automatically after discovering a new dependency might have an advantage: by doing that build immediately for the package itself (before building any packages that depend on it), it means the packages that depend on it won't have to be rebuilt a second time as well. That could save a lot of time. |
Thank you @borsboom for the explanation. In our situation many packages have to be rebuilt. As you pointed out these packages would not have to be rebuilt if haskell-src-exts wouldn't have been left in the dirty state directly after its build or if it had been immediately built twice. Would it be possible to add that behavior as an option? |
While we were brainstorming about this, @snoyberg came up with a great solution:
This way the second redundant build will not be needed in the vast majority of cases, but we'll still do the safe thing if a file is changed during the build. |
Sounds great! Thank you very much looking into this issue. I'm already looking forward to the next stack release. :-) |
This should now be fixed in master. Please re-open if you still experience trouble. |
Yay! On Sun, Sep 20, 2015, 3:43 AM Emanuel Borsboom [email protected]
|
Thank's a lot, @borsboom! It's working like a charm! :-) |
* master: (106 commits) Fix ghci -package-id for lib dep from test #1222 Fix passing of include dirs to GHCI #1222 Minor change to some local var naming Fix a copy-o which breaks ghci test targets #1222 Only ask for commit count once when compiling Move Windows installers above manual download Import all modules after loading them (#995) replace if then else with case matching (multiway if) Control/Concurrent/Execute.hs : redundant do Use stack setup so you can ignore most of the output Don't cache the GHC folder Strip -static before passing to GHCi (#1094) Fix: unlisted files in tests and benchmarks trigger extraneous second build (fixes #838) Don't fail when registering/looking up library for executable-only packages #1232 Fix help for default true bool flag's enable hint Rebuild when cabal file is changed watched command: show files, not directories Update changelog Fix: Haddocks not copied for dependencies (fixes #1105) Remove redundant Version from InstalledMap ...
When the stack.yaml includes a dependency from github and doing
stack build
twice, the second command isn't a no-op despite the first command being successful. If doingstack build
a third time it is, however. During the secondstack build
run, stack unregisters the github package saying "local file changes" and reinstalls them again. Diffing the package folder in .stack-work/downloaded before and after the second command reveals that only one file changed:downloaded/<package>/.stack-work/dist/x86_64-osx/Cabal-1.22.4.0/stack-build-cache
I can reproduce this on OS X with the following .cabal and stack.yaml content:
foobar.cabal:
stack.yaml:
The text was updated successfully, but these errors were encountered: