What's the best workaround for not having “cabal upgrade”?

依然范特西╮ 提交于 2019-11-28 15:19:13

问题


I want to upgrade all packages, not just a specific one with cabal install --upgrade-dependencies.


回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/6905163/whats-the-best-workaround-for-not-having-cabal-upgrade

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!