Search code examples
haskellcabalcabal-install

Upgrade package dependencies using Cabal


I have a script that deploys a Haskell program once a day. It currently does:

cabal update
cabal install --only-dependencies
cabal configure
cabal build

Which ensures it has the latest package index list, upgrades any dependency whose lower bound in the project.cabal has changed, and builds the code.

However, I'd really like to upgrade any dependency that has a new suitable version.

  • I tried adding --upgrade-dependencies but that refused to upgrade anything because it would break existing packages.
  • I tried combining that with --force-reinstalls, but it installed a new version of template-haskell (not a good idea) and things like QuickCheck would no longer compile.

What is the right way to upgrade packages automatically?


Solution

  • Upgrade to Cabal 2.0.0.0 or above.

    From Cabal 2.0.0.0 it no longer upgrades template-haskell, as per the changelog:

    • Made the 'template-haskell' package non-upgradable again (#4185).

    So --upgrade-dependencies --force-reinstalls works with newer versions.