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
{{ message }}
Unable to detect file changes on hamlet templates on stack devel for lts-12.5 #1551
On a new project initialized with the yesod templates, with the resolver automatically set to lts-12.5, hamlet templates are not watched. That is, running yesod devel fails to rebuild the app on changes to the template files.
Tested on both macos 10.13.6 and Ubuntu 18.04.
What worked however is changing the stack resolver from the picked up lts-12.5 stack resolver to lts-11.20.
Running watched command from stack build --file-watch confirms that the hamlet files are missing when on lts-12.5, but are present on lts-11.20.
That's most likely a different in how GHC is reporting the watched files in the two different versions. There should be some .hi-dump files in your .stack-work directory. Can you report whether those files reference your Hamlet files with the two different resolvers?
Good catch, looks like Stack needs to be updated to support that hex. I'm running out for the weekend right now, but a patch along these lines would probably do the trick. But I won't be able to try this out myself until next week:
diff --git a/src/Stack/Package.hs b/src/Stack/Package.hs
index ef986e95..d5ceb779 100644
--- a/src/Stack/Package.hs+++ b/src/Stack/Package.hs@@ -1184,8 +1184,9 @@ parseDumpHI dumpHIPath = do
-- It can be an absolute or relative path.
mapMaybe
(fmap TL.unpack .
- (TL.stripSuffix "\"" <=< TL.stripPrefix "\"") .- TL.dropWhileEnd (== '\r') . TLE.decodeUtf8 . CL8.dropWhile (/= '"')) $+ TL.stripPrefix "\"" .+ -- Starting with GHC 8.4.3, there's a hash following the path+ TL.takeWhile (/= '\"') . TLE.decodeUtf8 . CL8.dropWhile (/= '"')) $
filter ("addDependentFile \"" `CL8.isPrefixOf`) dumpHI
thDepsResolved <- liftM catMaybes $ forM thDeps $ \x -> do
mresolved <- liftIO (forgivingAbsence (resolveFile dir x)) >>= rejectMissingFile
Even with versions of stack that include the linked fix, yesod devel still does not detect changes to hamlet files.
In GHC 8.2 and earlier, referenced hamlet files appear as addDependentFile lines in the .dump-hi file. But in GHC 8.4 these lines do not appear. That appears to be the cause of the problem.
The problem was that you also need shakespeare >= 2.0.19, which is only in the latest LTS 12.14. Thanks to @tolysz for pointing that out. You need stack >= 1.9.3 (not yet released) to get @snoyberg's fix, or in the meantime you can build >= 1.9.2 from the stable branch on github.
I am now convinced that this issue is fixed. Thanks!
@ygale I just realised I posted this in the yesod tracker, rather than stack. But, when I comment out the addDependentFile line in my TH code, it works; when I leave it in, it gets permission errors.
Activity
snoyberg commentedon Aug 10, 2018
That's most likely a different in how GHC is reporting the watched files in the two different versions. There should be some
.hi-dumpfiles in your.stack-workdirectory. Can you report whether those files reference your Hamlet files with the two different resolvers?jvliwanag commentedon Aug 10, 2018
Looks like they point to the same file, but have the 12.5 has an additional hex string.
11.20 (working auto build)
Path:
./.stack-work/dist/x86_64-osx/Cabal-2.0.1.0/build/src/Handler/Home.dump-hi12.5 (auto build not working)
Path:
./.stack-work/dist/x86_64-osx/Cabal-2.2.0.1/build/src/Handler/Home.dump-hisnoyberg commentedon Aug 10, 2018
Good catch, looks like Stack needs to be updated to support that hex. I'm running out for the weekend right now, but a patch along these lines would probably do the trick. But I won't be able to try this out myself until next week:
Handle hash at the end of addDependentFile
Handle hash at the end of addDependentFile
Handle hash at the end of addDependentFile
Handle hash at the end of addDependentFile
Use stack clean when building.
ygale commentedon Oct 24, 2018
Even with versions of stack that include the linked fix,
yesod develstill does not detect changes to hamlet files.In GHC 8.2 and earlier, referenced hamlet files appear as
addDependentFilelines in the.dump-hifile. But in GHC 8.4 these lines do not appear. That appears to be the cause of the problem.Handle hash at the end of addDependentFile
ygale commentedon Oct 25, 2018
I am still experiencing this issue. Perhaps it should be re-opened?
The underlying stack issue is commercialhaskell/stack#4360.
ygale commentedon Oct 25, 2018
The problem was that you also need shakespeare >= 2.0.19, which is only in the latest LTS 12.14. Thanks to @tolysz for pointing that out. You need stack >= 1.9.3 (not yet released) to get @snoyberg's fix, or in the meantime you can build >= 1.9.2 from the stable branch on github.
I am now convinced that this issue is fixed. Thanks!
spacekitteh commentedon Jan 31, 2019
I'm not. I just updated to 1.9.3, and addDependentFile generates the following error from within GHC:
*** Core Linted result of Desugar (after optimization): *** Deleting temp files: Deleting: C:\Users\SPACEK~1\AppData\Local\Temp\ghc3940_0\ghc_1.hscpp C:\Users\SPACEK~1\AppData\Local\Temp\ghc3940_0\ghc_3.hscpp C:\Users\SPACEK~1\AppData\Local\Temp\ghc3940_0\ghc_5.hscpp *** Deleting temp dirs: Deleting: C:\Users\SPACEK~1\AppData\Local\Temp\ghc3940_0 C:\Users\spacekitteh: openBinaryFile: permission denied (Permission denied)ygale commentedon Feb 2, 2019
@spacekitteh Could you please post more details? So far I don't see the connection with
addDependentFile. Thanks!spacekitteh commentedon Feb 2, 2019
@ygale I just realised I posted this in the yesod tracker, rather than stack. But, when I comment out the addDependentFile line in my TH code, it works; when I leave it in, it gets permission errors.