Using Stack 1.4.0 on Windows:
git clone https://github.com/ndmitchell/hlint.git && cd hlintstack initstack buildstack exec where hlint - says something like c:\Neil\hlint\.stack-work\install\60f100ec\bin\hlint.exedel c:\Neil\hlint\.stack-work\install\60f100ec\bin\hlint.exestack build - nothing happens, but it should detect that the output file is missing and rebuild it.I suggest that if the output file no longer exists then stack rebuilds the inputs. Note that Shake takes this approach for build rules, rebuilding if either the inputs _or the outputs_ have changed.
I can reproduce this on OS X, on stack itself, with rm .stack-work/install/x86_64-osx/lts-6.25/7.10.3/bin/stack. I thought that's because this is, for Cabal, an installation step.
What I find worse, though, is that rm .stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/Stack/stack also does not trigger a rebuild.
Maybe because Cabal doesn't track binaries? Also rm .stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/libHSstack-1.4.1-JAZEAA7MgYMKhDOQquMlls* doesn't help.
@ndmitchell Any chance this is a bug with the Cabal library itself?
I have no idea which of cabal/stack is at fault - but often stack will work around cabal bugs anyway so raising to stack is my first step.
Not sure if Cabal will detect the missing file and cause a rebuild. Certainly to handle this, stack's dirtiness checker would need to be amended.
Not sure if I'd consider it a bug, particularly for the exe at the install location. However, I can certainly understand the expectation that output removal would cause recompilation. PRs appreciated!
For context, if the copy fails (e.g. out of disk space, file locked) then you get the same behaviour of not rebuilding, which I'd say was a bug. However, reproducing that condition is super difficult.
It seems that when doing a build, Stack finds out if any source files were changed before proceeding. I've found that when I add a space or empty newline to say src/Main.hs that does nothing, stack build then works and generates the executable.
An example of this being a problem: https://stackoverflow.com/questions/47638079/reinstalling-intero-using-stack . Using @Blaisorblade 's example of rm .stack-work/install/x86_64-osx/lts-6.25/7.10.3/bin/stack, the workaround is to also do rm .stack-work/install/x86_64-osx/lts-6.25/7.10.3/installed-packages/stack-* (or use the specific version instead of *
Makes sense to check for the output exe and rebuild if it doesn't exist.
I don't understand @mgsloan 's workaround – the only other file I find in installed-packages is happy – will stack finally reinstall profiteur for me if I delete happy? I'm a bit afraid to try now that I can't even get profiteur installed (I'd rather not have to rm -rf ~/.stack and wait half a day to be productive again). stack obviously tracks that profiteur was installed, since it's not rebuilding it, so where does it track that?
EDIT: It seems rm -rf .stack in the project folder worked :-)