I find cabal's behavior when installing packages maddening. For example, running
cabal install funsat
installed old versions of array, time, random, quickcheck, and bitset, breaking packages like monadiccp, hoogle, heist, snap, etc.
It works to go back and cabal install monadiccp, etc., but how can I avoid the default behavior of cabal breaking installed packages? Any reasonable Linux package manager, like aptitude or zypper would ask whether I wanted to break already installed packages, when installing a new package.
Has anyone cooked up a workaround script? Thanks in advance.
I recommend cabal-dev, which maintains a separate set of installed packages for each project you work on. That doesn't solve the bad behaviour of cabal-install in general, but means that such failures are more isolated than they would otherwise be, and allows you to fix them more easily by simply doing cabal-dev clean && cabal-dev install.
The added benefit of reproducible builds is also nice.
Admittedly, this isn't a workaround for your specific problem, but it lessens cabal-install pain in general.
Building on Daniel Fischer's answer, here's a wrapper for cabal that aborts an installation if it would reinstall a package:
cabal () {
if [ "$1" = "install" ]; then
local out=$(command cabal --dry-run -v2 "$@" 2>&1)
if echo "$out" | egrep -c '\((reinstall|new version)\)' >/dev/null; then
echo "$out"
return 1
fi
fi
command cabal "$@"
}
YMMV; I've only lightly tested this and it causes an annoying delay at start-up as all the dependencies have to be calculated twice. But it should relieve some tedium if you want to stay on the safe side.
Workaround: always check with --dry-run first. If cabal would reinstall any package, watch out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With