I want to upgrade all packages, not just a specific one with cabal install --upgrade-dependencies
.
This bit of shell hackery works for me on OS X:
cabal list --simple-output --installed | awk '{print $1}' | uniq | xargs -I {} cabal install {} --reinstall
EDIT: Now forces a reinstall, and avoids installing a package more than once when more than one version is present. Thanks for the comments!
EDIT YEARS LATER: Now that Cabal sandboxes and Stack exist, I strongly recommend against trying to upgrade packages in place. You'll end up with far fewer headaches if you instead can just wipe out an existing sandbox and reinstall up-to-date dependencies.
The .cabal/world
file contains a list of every package you installed explicitly (listed in a cabal install
command, as opposed to pulled through dependencies). Trim it to remove packages that are only useful as dependencies, packages that are deprecated, and version-locked packages that you'd rather upgrade.
Cabal doesn't know how to clean-up after itself, but you can remove almost everything. The next command will reinstall from .cabal/packages
(a tarball cache):
cp -t bin .cabal/bin/cabal
rm -rf .cabal/{bin,lib,share} .ghc/*-*-*/
ghc-pkg check |&egrep -- '^[A-Za-z0-9-]+-[0-9]' |xargs -n1 --no-run-if-empty ghc-pkg unregister
Now reinstall everything that was manually installed:
cabal install world --upgrade-dependencies --force-reinstalls
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