Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Find out which flags have changed #921

Open
dspies-leapyear opened this issue Dec 15, 2017 · 5 comments
Open

Find out which flags have changed #921

dspies-leapyear opened this issue Dec 15, 2017 · 5 comments

Comments

@dspies-leapyear
Copy link

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?)

@dspies-leapyear
Copy link
Author

dspies-leapyear commented Dec 15, 2017

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

@DanielG
Copy link
Owner

DanielG commented Dec 17, 2017

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.

@dspies-leapyear
Copy link
Author

dspies-leapyear commented Dec 18, 2017

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?

@dspies-leapyear
Copy link
Author

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?

@DanielG
Copy link
Owner

DanielG commented Dec 18, 2017

Can you paste the output of ghc-mod debug run from one of the project directories somewhere please?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants