orome
orome

Reputation: 48436

Is there a way to use Cabal to keep Haskell packages up-to-date?

I'm confused by how Cabal works. I'm used to packages managers that have as part of their core functionality the ability to easily update all packages that have changed, or at least to get a list of packages on my system that have updates available. But Cabal seems to lack this functionality. Am I missing something?

Is there a way to:

  1. Automatically or easily update all out-of-date packages; or, failing that,
  2. Get a list of packages installed on my system that have updates available?

Upvotes: 9

Views: 4395

Answers (1)

Daniel Wagner
Daniel Wagner

Reputation: 152682

Warning: For some reason, this question seems to be getting some traffic again in 2023. Please keep in mind that this answer was written before cabal's nix-style build apparatus existed. The modern answer to this question is that the question shouldn't exist; you can still install executables, but installing libraries is no longer the preferred usage mode, so upgrading all the installed libraries is also gone. Instead, each package is built in its own isolated cubby of the Haskell world, with library dependencies resolved independently of what is currently installed.


There are a number of standard package-management features missing from cabal. This is one of them, and (transitive) removal of packages is another. The party line is that cabal is intended to be an automatic build tool, nothing more; though that line grows thinner and thinner as the years drag on.

If you know which packages you want to upgrade, you can; generally cabal update and cabal install those packages will grab the newest package list from Hackage and try to find an install plan that installs the newest versions of the requested packages. You can ask for the install plan without executing it with cabal install --dry-run those packages; if it doesn't look like it picked the versions you want, you can add constraints, as in

cabal install those packages --constraint 'those>=9000'

Upvotes: 17

Related Questions