2

I am trying to install the specific version template-haskell-2.17.0.0. I run this command, but get an error during dependency resolution:

❯ cabal install template-haskell-2.17.0.0 --lib
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] next goal: template-haskell (user goal)
[__0] rejecting: template-haskell-2.18.0.0 (constraint from user target
requires ==2.17.0.0)
[__0] rejecting: template-haskell-2.17.0.0 (constraint from user target
requires ==2.16.0.0)
[__0] rejecting: template-haskell-2.16.0.0/installed-2.16.0.0,
template-haskell-2.16.0.0, template-haskell-2.15.0.0,
template-haskell-2.14.0.0, template-haskell-2.13.0.0,
template-haskell-2.12.0.0, template-haskell-2.11.1.0,
template-haskell-2.11.0.0, template-haskell-2.10.0.0,
template-haskell-2.9.0.0, template-haskell-2.8.0.0, template-haskell-2.7.0.0,
template-haskell-2.6.0.0, template-haskell-2.5.0.0, template-haskell-2.4.0.1,
template-haskell-2.4.0.0, template-haskell-2.3.0.1, template-haskell-2.3.0.0,
template-haskell-2.2.0.0 (constraint from user target requires ==2.17.0.0)
[__0] fail (backjumping, conflict set: template-haskell)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: template-haskell

I'm using the latest cabal version:

❯ cabal --version
cabal-install version 3.6.2.0
compiled using version 3.6.3.0 of the Cabal library
  • 1
    I'm not 100% sure on this but I think TH is one of the "boot" packages that can't really be meaningfully upgraded. You need to change compiler version to change TH version. It seems plausible that the stuff that it does is just too intertwined with compiler internals. You might like [this wiki page](https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/libraries/version-history) outlining the compiler<->library version connections. – Daniel Wagner Apr 19 '22 at 18:32
  • 1
    As far as I know the template Haskell package is "hardwired" to the compiler version, and you thus should use `2.16.0.0` in this case. – Willem Van Onsem Apr 19 '22 at 19:37
  • Is there a way to configure cabal to use a more recent compiler version, so that I can use `template-haskell-2.17.0.0`? – Henry Blanchette Apr 19 '22 at 20:35
  • Related questions: https://stackoverflow.com/q/71173561/1274282, https://stackoverflow.com/q/71092123/1274282 & https://stackoverflow.com/q/68558825/1274282. Also this issue is related to the error message itself: https://github.com/haskell/cabal/issues/7993. – Taylor Fausak Apr 19 '22 at 20:49

1 Answers1

2

Some packages come with GHC and cannot be reinstalled. These are known as "boot" packages. The template-haskell package is one of these boot packages. You can find a complete list of them here: https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/libraries/version-history.

For your particular case, template-haskell-2.17.0.0 is part of GHC 9.0.2 (or 9.0.1). The only way to install that version of template-haskell is to use the appropriate version of GHC.

Based on the error output, I'm guessing that you're using some version of GHC 8.10.x, probably 8.10.7. You don't mention how you installed GHC, so I don't know exactly how to tell you to upgrade. If you used GHCup, then you should be able to upgrade GHC with this command:

ghcup install ghc 9.0.2 --set
Taylor Fausak
  • 1,106
  • 8
  • 12
  • 1
    Some boot packages _can_ be reinstalled / upgraded, e.g. `containers`. I believe it's only the builtin packages than can not be reinstalled, i.e. those that are developed within the GHC source tree: https://gitlab.haskell.org/ghc/ghc/-/tree/master/libraries – sjakobi Apr 20 '22 at 21:45