haskellcabal

Cabal: Can't install a specific version of the package (with message "only already installed instances can be used")


I've been trying to install some package:

PS C:\Users\Neo> cabal install template-haskell-2.15.0.0
Resolving dependencies...
cabal-3.6.2.0.exe: Could not resolve dependencies:
[__0] next goal: template-haskell (user goal)
[__0] rejecting: template-haskell-2.19.0.0, template-haskell-2.18.0.0,
template-haskell-2.17.0.0, template-haskell-2.16.0.0 (constraint from user
target requires ==2.15.0.0)
[__0] rejecting: template-haskell-2.15.0.0 (only already installed instances
can be used)
[__0] rejecting: 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.15.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

What does the message "only already installed instances can be used" actually mean?


Solution

  • Like base, but unlike most other packages, template-haskell is non-reinstallable, basically meaning that it's tied to your GHC version and can't be installed, upgraded, or downgraded separately. Cabal's source code has the full list of such packages. That's what "only already installed instances can be used" means. (For future readers, "constraint from non-upgradeable package requires installed instance" and "constraint from non-reinstallable package requires installed instance" instead mean the same thing as it.)

    Ideally, the package you're trying to install should be updated to work with newer versions of GHC, but if you really need to downgrade to template-haskell-2.15.0.0, then you can do so by downgrading to GHC 8.8.4. GHC Boot Library Version History on the GHC Wiki has a table of which GHC version corresponds to which library versions. (Note that there are a lot of GHC boot libraries besides just the non-reinstallable ones.)