Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between `stack clean` and removing the `.stack-work` directory?

1 Context

I am involved in a Haskell project that involves lots of C-bits and FFI. So I find myself frequently running and re-running commands like

$ stack build
$ stack build --force-dirty
$ stack clean
$ rm ./.stack-work

over and over in order for the C-bits to be linked properly to the Haskell bits. Put differently, sometimes things just work when running stack build, and sometimes they don't (in which case I'm forced to cycle through the above commands over and over until my project builds properly).

This means I don't have a proper understanding of how stack (through ghc) assembles the C-bits before assembling the Haskell bits. So here is one question to help me start clearing up my confusion:

2 Question

Are there any noteworthy difference between running stack clean and deleting the contents of the .stack-work directory? Are there cases where deleting the .stack-work directory is needed as a good precaution to ensure that you are actually running a clean build?

like image 414
George Avatar asked Jan 10 '17 17:01

George


1 Answers

As you can see by reading the source here:

https://github.com/commercialhaskell/stack/blob/master/src/Stack/Clean.hs

There are two levels, full and shallow. I think shallow seems to be the default. It seems to be able to clean specific packages, or if you don't provide no options at all, it'll clean everything but extra-deps in local packages.

like image 145
Julian Leviston Avatar answered Jan 09 '23 13:01

Julian Leviston