haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.61k stars 691 forks source link

Pre-release and multi-repl incompatible with Custom setup #9632

Open TeofilC opened 8 months ago

TeofilC commented 8 months ago

Describe the bug Cabal's multi-repl support requires a version of the Cabal library >=3.11. This is fine when using cabal-install's builtin copy of the Cabal library. But when packages' Custom setups require Cabal as build dependency, we run into problems as this version is not yet released, so not available on Hackage, and it's not the version bundled with the user's GHC.

To Reproduce Try using a pre-release cabal to run

cabal repl --enable-multi-repl --allow-newer postgresql-libpq
Output ``` Warning: this is a debug build of cabal-install with assertions enabled. Resolving dependencies... Error: [Cabal-7107] Could not resolve dependencies: ... [__1] trying: postgresql-libpq-0.10.0.0 (dependency of eventstore) [__2] next goal: postgresql-libpq:setup.Cabal (dependency of postgresql-libpq) [__2] rejecting: postgresql-libpq:setup.Cabal-3.10.2.0/installed-inplace, postgresql-libpq:setup.Cabal-3.10.2.1, postgresql-libpq:setup.Cabal-3.10.2.0, postgresql-libpq:setup.Cabal-3.10.1.0, postgresql-libpq:setup.Cabal-3.8.1.0, postgresql-libpq:setup.Cabal-3.6.3.0, postgresql-libpq:setup.Cabal-3.6.2.0, postgresql-libpq:setup.Cabal-3.6.1.0, postgresql-libpq:setup.Cabal-3.6.0.0, postgresql-libpq:setup.Cabal-3.4.1.0, postgresql-libpq:setup.Cabal-3.4.0.0, postgresql-libpq:setup.Cabal-3.2.1.0, postgresql-libpq:setup.Cabal-3.2.0.0, postgresql-libpq:setup.Cabal-3.0.2.0, postgresql-libpq:setup.Cabal-3.0.1.0, postgresql-libpq:setup.Cabal-3.0.0.0, postgresql-libpq:setup.Cabal-2.4.1.0, postgresql-libpq:setup.Cabal-2.4.0.1, postgresql-libpq:setup.Cabal-2.4.0.0, postgresql-libpq:setup.Cabal-2.2.0.1, postgresql-libpq:setup.Cabal-2.2.0.0, postgresql-libpq:setup.Cabal-2.0.1.1, postgresql-libpq:setup.Cabal-2.0.1.0, postgresql-libpq:setup.Cabal-2.0.0.2, postgresql-libpq:setup.Cabal-1.24.2.0, postgresql-libpq:setup.Cabal-1.24.0.0, postgresql-libpq:setup.Cabal-1.22.8.0, postgresql-libpq:setup.Cabal-1.22.7.0, postgresql-libpq:setup.Cabal-1.22.6.0, postgresql-libpq:setup.Cabal-1.22.5.0, postgresql-libpq:setup.Cabal-1.22.4.0, postgresql-libpq:setup.Cabal-1.22.3.0, postgresql-libpq:setup.Cabal-1.22.2.0, postgresql-libpq:setup.Cabal-1.22.1.1, postgresql-libpq:setup.Cabal-1.22.1.0, postgresql-libpq:setup.Cabal-1.22.0.0, postgresql-libpq:setup.Cabal-1.20.0.4, postgresql-libpq:setup.Cabal-1.20.0.3, postgresql-libpq:setup.Cabal-1.20.0.2, postgresql-libpq:setup.Cabal-1.20.0.1, postgresql-libpq:setup.Cabal-1.20.0.0, postgresql-libpq:setup.Cabal-1.18.1.7, postgresql-libpq:setup.Cabal-1.18.1.6, postgresql-libpq:setup.Cabal-1.18.1.5, postgresql-libpq:setup.Cabal-1.18.1.4, postgresql-libpq:setup.Cabal-1.18.1.3, postgresql-libpq:setup.Cabal-1.18.1.2, postgresql-libpq:setup.Cabal-1.18.1.1, postgresql-libpq:setup.Cabal-1.18.1, postgresql-libpq:setup.Cabal-1.18.0, postgresql-libpq:setup.Cabal-1.16.0.3, postgresql-libpq:setup.Cabal-1.16.0.2, postgresql-libpq:setup.Cabal-1.16.0.1, postgresql-libpq:setup.Cabal-1.16.0, postgresql-libpq:setup.Cabal-1.14.0, postgresql-libpq:setup.Cabal-1.12.0, postgresql-libpq:setup.Cabal-1.10.2.0, postgresql-libpq:setup.Cabal-1.10.1.0, postgresql-libpq:setup.Cabal-1.10.0.0, postgresql-libpq:setup.Cabal-1.8.0.6, postgresql-libpq:setup.Cabal-1.8.0.4, postgresql-libpq:setup.Cabal-1.8.0.2, postgresql-libpq:setup.Cabal-1.6.0.3, postgresql-libpq:setup.Cabal-1.6.0.2, postgresql-libpq:setup.Cabal-1.6.0.1, postgresql-libpq:setup.Cabal-1.4.0.2, postgresql-libpq:setup.Cabal-1.4.0.1, postgresql-libpq:setup.Cabal-1.4.0.0, postgresql-libpq:setup.Cabal-1.2.4.0, postgresql-libpq:setup.Cabal-1.2.3.0, postgresql-libpq:setup.Cabal-1.2.2.0, postgresql-libpq:setup.Cabal-1.2.1, postgresql-libpq:setup.Cabal-1.1.6, postgresql-libpq:setup.Cabal-1.24.1.0 (constraint from --enable-multi-repl requires >=3.11) [__2] fail (backjumping, conflict set: postgresql-libpq, postgresql-libpq:setup.Cabal) After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: postgresql-libpq:setup.Cabal, eventstore, postgresql-libpq ```

Expected behavior This should work fine

Workaround

We can work around this issue by adding Cabal and Cabal-syntax to our cabal.project using a source-repository-package, eg:

source-repository-package
    type: git
    location: https://github.com/haskell/cabal.git
    subdir: Cabal

source-repository-package
    type: git
    location: https://github.com/haskell/cabal.git
    subdir: Cabal-syntax
fgaz commented 8 months ago

This is expected. The multi-repl functionality needs Cabal>=3.11, and cabal-install can't conjure it from nothing.

What do you suggest should happen?

TeofilC commented 8 months ago

I think maybe the best we can do is document the workaround somewhere.

I guess if it was possible it would be good to be able to bundle the Cabal and Cabal-syntax libraries with cabal-install for pre-releases, but I don't think that's doable (or at least not easily)

Bodigrim commented 8 months ago

@TeofilC thanks for figuring out the workaround! I hit the same issue recently.

mpickering commented 6 months ago

See #9741 for an idea about how to tackle this.

andreabedini commented 6 months ago

Definitely this should be documented somewhere but TBH it is not an issue that has to be fixed. As @fgaz says, Cabal 3.11 hasn't been released yet and source-repository-package is the way to get a package from github.

TeofilC commented 6 months ago

I forgot to link to it here, but I've already added some documentation of this to the README in the static pre-releases patch: https://github.com/haskell/cabal/blob/9025af597b905f2027a878c0aa0f34b885e42a6e/README.md?plain=1#L50-L61