Search code examples
haskellghc

How to fix missing dependencies after deleting GHC's snapshots?


My C: drive was full, so I decided to remove all Haskell snapshots older than two month, knowing it could cause trouble.

And it did :

ghc-9.8.2.exe: addLibrarySearchPath: \\?\C:\sr\snapshots\d22c45cb\lib\x86_64-windows-ghc-9.8.2 : 
The system cannot find the path specified.

[8 of 8] Compiling Paths_semigroup_extras
<no location info>: error:
    addDLL: HSgroups-0.5.3-IYEy0wlfuCnJAATXPgKDMS or dependencies not loaded. 

Since it actually didn't cause trouble for my every day projects, I thought everything was fine and I flushed the Recycle Bin, so I can't recover the snapshots. This only happened when I try to compile an older project.

How can I deal with this ?

I tried stack clean --full and deleting the .stack-works folder but I feel the problem comes from GHC.


Solution

  • If like me, you just want to purge your snapshots folder to gain some space on your hard drive, the best way is to actually delete ALL snapshot folders instead of trying to keep the recent ones.

    This will force GHC to create new healthy snapshots. Your next build will take a long time though.