Skip to content

Instantly share code, notes, and snippets.

@p-alik
Forked from timmytofu/ghcPkgUtils.sh
Last active February 2, 2020 19:38
Show Gist options
  • Save p-alik/4f8cc64ace8a20a8bebcb8e8e1cba2a4 to your computer and use it in GitHub Desktop.
Save p-alik/4f8cc64ace8a20a8bebcb8e8e1cba2a4 to your computer and use it in GitHub Desktop.
ghc-pkg-clean and ghc-pkg-reset compatible with both zsh and bash
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages.
# ghc-pkg-clean -f cabal/dev/packages*.conf also works.
function ghc-pkg-clean() {
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'`
do
echo unregistering $p; ghc-pkg $* unregister $p
done
}
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place.
# When all else fails, use this to get out of dependency hell and start over.
function ghc-pkg-reset() {
printf '%s' "Erasing all your user ghc and cabal packages - are you sure (y/N)?"
read ans
[[ "x$ans" =~ "xy" ]] && ( \
echo 'erasing directories under ~/.ghc'; command rm -rf `find ~/.ghc/* -maxdepth 1 -type d`; \
echo 'erasing ~/.cabal/lib'; command rm -rf ~/.cabal/lib; \
)
}
alias cabalupgrades="cabal list --installed | egrep -iv '(synopsis|homepage|license)'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment