I often install a package which depends on external libraries and manage to move those external libraries to other locations afterwards, so that compiled programs exit with
Update:
Based on @Michael Snoyman's comment just using this command should be enough to remove the package:
stack exec -- ghc-pkg unregister --force regex-pcre
Original Answer:
I don't know if it's the sanctioned way to do it, but it seems to work. Here is a synopsis:
ghc-pkg
program for the version of GHC you are using$ghcpkg --package-db $pkgdb unregister --force <package>
precompiled
directorySuppose the package we want to remove is zlib-0.5.4.2
.
Locating ghc-pkg
Under ~/.stack/programs find the ghc-pkg program appropriate for your compiler version, e.g. ~/.stack/programs/x86_64-osx/ghc-7.10.2/bin/ghc-pkg
. Call this $ghcpkg
Locating the package db
Under ~/.stack/snapshots find the pkgdb
directory for the resolver you are using, e.g. ~/.stack/snapshots/x86_64-osx/lts-3.1/7.10.2/pkgdb
. Call this $pkgdb
.
Unregister the package
Run:
$ghcpkg --package-db $pkgdb unregister --force zlib-0.5.4.2
Ignore any warnings about broken or breaking packages.
You can check to see if your package is registered or not with this command:
$ghcpkg --package-db $pkgdb list | grep zlib
Remove the package from the precompiled
directory
Under ~/.stack/precompiled
locate any directories named zlib-0.5.4.2
and remove the one for your the relevant version of GHC:
find ~/.stack/precompiled -name 'zlib-*'
/bin/rm -rf ...
Reinstall the package
stack --resolver=... install zlib
Stack should report that it is rebuilding the package.