ghc-mod
ghc-mod copied to clipboard
Find out which flags have changed
Often ghc-mod seems to rebuild more than necessary because it's passing a different set of flags to ghc then those that were originally used to build the dependencies. How can I find out which flags ghc thinks has changed? (and to what?)
When running with --verbose 7
I get
$ ghc-mod --verbose 7 list
info: Found Stack project at: /Users/davidspies/workspace/myproject
info: Using Stack project at: /Users/davidspies/workspace/myproject
DEBUG: setup configuration is out of date
DEBUG: reconfiguring Stack project
and then it proceeds to unregister and rebuild everything
The list command shouldn't actually start a GHC session in ghc-mod, it does however invoke stack build
as necessary to update the Cabal configuration. I think that's the compilation you're seeing. Now the output above indicates that ghc-mod thinks you edited your .cabal
file or more technically the .stack-work/**/setup-config file's modtime was older than your-project.cabal's. If this is true then it's perfectly alright for it to invoke stack build
to get that updated. It shouldn't actually rebuild your entire project though, ~~only dependencies and even those should already be cached~~ we actually don't even do that by default anymore. The stack command we use is: stack build --only-configure .
. The relevant code is here: https://github.com/DanielG/ghc-mod/blob/master/core/GhcMod/CabalHelper.hs#L165 if you wan to have a look.
Ok, I think I get it now. Our project is configured like:
project:
stack.yaml
.stack-work
projectsomepackage:
projectsomepackage.cabal
src/Project/Some:
MyModule.hs
MyModuleDependency.hs
projectotherpackage:
projectotherpackage.cabal
src/Project/Other:
OtherModule.hs
If I try to run ghc-mod check $HOME/project/projectsomepackage/src/Project/Some/MyModule.hs
from inside project/projectsomepackage
then it expects the .stack-work
directory to be there as well so when it doesn't find anything, it attempts to build.
On the other hand if I run from within the root-level project
directory, then it treats projectsomepackage
as a dependency and complains about Project.Some.MyModuleDependency
being a hidden module in the package projectsomepackage
. What should I do?
Oh, but also, there's still no setup-config
file. We're actually using shake
which in turn calls stack
, but maybe it does something to prevent that file from being generated. What is the setup-config
file anyway? Do I need it? Can ghc-mod
work without it?
Can you paste the output of ghc-mod debug
run from one of the project directories somewhere please?