Neil Mitchell
Neil Mitchell

Reputation: 9250

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.

What is the right way to upgrade packages automatically?

Upvotes: 4

Views: 1559

Answers (2)

Neil Mitchell
Neil Mitchell

Reputation: 9250

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.

Upvotes: 2

Thomas M. DuBuisson
Thomas M. DuBuisson

Reputation: 64740

You could use cabal new-build and if you only want to upgrade most dependencies then freeze the few you wish to hold constant in a cabal.project.freeze file.

cat <<EOF >cabal.project.freeze
constraints: template-haskell == 2.13.0.0
EOF

And

cabal update
# Perhaps rm -rf dist-newstyle if you want a completely fresh build
cabal new-build --upgrade-dependencies

Upvotes: 2

Related Questions