haskell stack memopublished : June 8, 2018
How to rebuild precompiled packages
In some cases, stack says that precompiled packages are broken. This problem will solve following steps.
- unregister package by ghc-pkg
- delete precompiled package files of stack
In following instruction, the target package name will denote as “package”. In stack message, the pakcage name is denote with version number, like “package-1.0.1”.
1. unregister package by ghc-pkg
stack exec -- ghc-pkg unregister --force package
stack exec -- ghc-pkg list | grep package
When there are several version of GHC, these commands may not work well. Then do below.
- find ghc-pkg manageing the target pakcage
- ex : ~/.stack/programs/x86_64-osx/ghc-7.10.2/bin/ghc-pkg
- $ghcpkg in following
- find database file
- ex : ~/.stack/snapshots/x86_64-osx/lts-3.1/7.10.2/pkgdb
- $pkgdb in following
- delete package
- do > $ghcpkg –package-db $pkgdb unregister –force package
- check deletion
- do > $ghcpkg –package-db $pkgdb list | grep package
2. delete precompiled package files of stack
find ~/.stack/precompiled -type d -name package-* | xargs rm -rf
Do “stack build”, “stack install …” or something. You may see that stack recompile the target pakcages.