Skip to content

stack build does not rebuild executable without other-modules #2341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spl opened this issue Jul 6, 2016 · 8 comments
Closed

stack build does not rebuild executable without other-modules #2341

spl opened this issue Jul 6, 2016 · 8 comments

Comments

@spl
Copy link

spl commented Jul 6, 2016

This may be a known issue. If so, I think it could be documented better. I could not find a clear answer in the issue archive to match this, so, at the very least, this issue might help others who encounter the problem.

Steps to reproduce:

  1. Create a .cabal for an executable.
    • Include the hs-source-dirs field mentioning the source directories with the modules.
    • Do not include the other-modules field with the modules listed.
  2. Create a stack from that .cabal.
  3. stack build the first time.
  4. Change a module in the package.
  5. stack build to rebuild.

Expected:

The project rebuilds.

Actual:

The project does not rebuild.

Discussion:

I couldn't figure out why my project wasn't rebuilding. Then, I found that if I include other-modules with a module M and update M, the project would rebuild. If I then change N, a module not listed in other-modules, the project would not rebuild.

Related:

These issues seem to be related:

From my cursory reading, it seems like this issue was supposed to be fixed in:

There seems to be a currently undocumented --force-dirty flag added in 09a9fa4 to deal with this kind of issue.

I believe I did see a warning for unlisted modules (added in 31712d3?), but I wasn't sure what the warning was for. I wasn't even sure what an “unlisted module” was. Why would unlisted modules be a problem? If this issue is the reason for that warning, then the warning text could be improved.

Questions:

If this is a known issue with no fix currently planned, could it be documented better or handled by stack?

  • One option would be to mention it somewhere in the guide. The “Build command” section would be a good place to start with.
  • Another option would be to automate the check with stack and report it.
@mgsloan
Copy link
Contributor

mgsloan commented Jul 26, 2016

Hey, thanks for the details! I tried

name:                issue2341
version:             0.1.0.0
cabal-version:       >=1.10

executable issue2341-exe
  main-is:             Main.hs
  build-depends:       base
  default-language:    Haskell2010

With Main.hs

import Lib

main = putStrLn "hi"

and Lib.hs

module Lib where

Changes to Lib cause rebuild despite not being listed in other-modules.

One option would be to mention it somewhere in the guide. The “Build command” section would be a good place to start with.

I've documented some more of the flags there, good idea!

@spl
Copy link
Author

spl commented Jul 27, 2016

@mgsloan: Thanks for trying to reproduce it. I take it from your response that this is not a known problem?

Two things to add:

  • I don't see hs-source-dirs in your .cabal. I had hs-source-dirs: src with all modules under the src/ directory.
  • This is a ghcjs project. I'm not sure if that makes a difference.

@spl
Copy link
Author

spl commented Jul 27, 2016

Also, thanks for improving the documentation. 💯

@mgsloan
Copy link
Contributor

mgsloan commented Oct 11, 2016

This is indeed related to using GHCJS. With GHC I get:

2016-10-10-180042_845x78_scrot

However, GHCJS doesn't seem to output these ddump-hi files, and so we can't keep track of dirtiness.

@mgsloan
Copy link
Contributor

mgsloan commented Oct 11, 2016

@spl I believe I've resolved the issue. Now, all local ghcjs packages will be assumed to be dirty, because we can't be sure.

Please re-open and comment if the git version of stack doesn't solve the problem for you.

@mgsloan mgsloan closed this as completed Oct 11, 2016
mgsloan added a commit that referenced this issue Oct 11, 2016
@spl
Copy link
Author

spl commented Oct 11, 2016

Nicely done. I think that's a reasonable solution. Thanks!

@mgsloan
Copy link
Contributor

mgsloan commented Oct 11, 2016

Welcome, thanks for bringing up the issue!

@mgsloan
Copy link
Contributor

mgsloan commented Oct 18, 2016

@spl I have figured out why ddump-hi files aren't being produced - see #2714 . I've fixed that issue, and reverted the special case of assuming ghcjs local packages are dirty.

mgsloan added a commit that referenced this issue Oct 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants