You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I add another executable (by adding an executable in package.yaml and adding a file in src directory), and run stack run <new executable name>, Stack rebuilds all other executables. I would like to know why does this happen. I guess it is because I used a bad project structure, but I have tried some other ways to organized the files and directories, and each structure has its own problems.
I wish Stack could provide some tips about how should people organize project files for different types of projects (e.g. 1 lib + 1 exe, 1 lib + many exe, 0 lib + many exe, etc.). A good project structure should mean that adding / removing / updating source files should always result in the minimum set of files recompiled.
The text was updated successfully, but these errors were encountered:
Purportedly due to a bug in some versions of Cabal (the library), the first time Stack builds any component of a local package, it builds all the executable components. So, for an example package foo with executables foo1 and foo2:
❯ stack ide targets
foo:lib
foo:exe:foo1-exe
foo:exe:foo2-exe
foo:test:foo-test
❯ stack build foo:lib # Just build the library components
Building all executables for foo once. After a successful build of all of them, only specified
executables will be rebuilt.
foo> configure (lib + exe)
...
Installing executable foo1-exe in D:\Users\mike\Code\Haskell\foo\.stack-work\install\3f52e67e\bin
Installing executable foo2-exe in D:\Users\mike\Code\Haskell\foo\.stack-work\install\3f52e67e\bin
Registering library for foo-0.1.0.0..
❯ stack build foo:lib # Second time around (nothing will build; already all built)
When you add a new executable component to an existing local package description, Stack knows it has to unregister the previous version of the package and re-build the 'new' package - and the above applies to the building of the 'new' package.
See #3486 for background to the bug in some versions of Cabal (the library). Stack may be able to move forward with this problem after Stack 2.15.1, because I am proposing that Stack cease supporting Cabal < 2.2. See #6377.
Example repo: https://github.com/SmartHypercube/aoc2023-haskell
When I add another executable (by adding an executable in
package.yaml
and adding a file insrc
directory), and runstack run <new executable name>
, Stack rebuilds all other executables. I would like to know why does this happen. I guess it is because I used a bad project structure, but I have tried some other ways to organized the files and directories, and each structure has its own problems.I wish Stack could provide some tips about how should people organize project files for different types of projects (e.g. 1 lib + 1 exe, 1 lib + many exe, 0 lib + many exe, etc.). A good project structure should mean that adding / removing / updating source files should always result in the minimum set of files recompiled.
The text was updated successfully, but these errors were encountered: