haskell / cabal

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

Cabal multi-repl fails with Custom buid type and the error message is not helpful #10602

Open noughtmare opened 6 days ago

noughtmare commented 6 days ago

Describe the bug

If I understand this blog post correctly, cabal 3.12.1.0 is supposed to have multi-component support. Unfortunately, trying to load multiple components with HLS still produces an error which contains this line:

The 'repl' command does not support multiple targets at once.

To Reproduce Steps to reproduce the behavior:

Expected behavior

No error.

System information

$ cabal --version
cabal-install version 3.12.1.0
compiled using version 3.12.1.0 of the Cabal library 

$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.6.6

$ haskell-language-server-wrapper --version
haskell-language-server version: 2.9.0.0 (GHC: 9.6.6) (PATH: /nix/store/w7h9j7ar2q1zk3dldh5adhbs85vm9kir-haskell-language-server-2.9.0.0/bin/haskell-language-server-wrapper)
ulysses4ever commented 1 day ago

Thanks for the report! Is there a reproducer without HLS and VS Code? If not, HLS repo may be a better place to start.

noughtmare commented 1 day ago

I can reproduce it with just cabal:

$ cabal repl --enable-multi-repl lib:agda test:agda-tests
Warning: The package list for 'hackage.haskell.org' is 39 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
Build profile: -w ghc-9.6.6 -O1
In order, the following will be built (use -v for more details):
 - Agda-2.8.0 (interactive) (configuration changed)
[1 of 2] Compiling Main             ( /home/user/haskell/agda/dist-newstyle/build/x86_64-linux/ghc-9.6.6/Agda-2.8.0/setup/setup.hs, /home/user/haskell/agda/dist-newstyle/build/x86_64-linux/ghc-9.6.6/Agda-2.8.0/setup/Main.o ) [Distribution.Simple.BuildPaths package changed]
[2 of 2] Linking /home/user/haskell/agda/dist-newstyle/build/x86_64-linux/ghc-9.6.6/Agda-2.8.0/setup/setup [Objects changed]
Configuring Agda-2.8.0...
Error: [Cabal-6091]
The 'repl' command does not support multiple targets at once.

Error: [Cabal-7125]
repl failed for Agda-2.8.0.
noughtmare commented 1 day ago

It seems that this is specific to Agda. Running this command on a fresh cabal project with a library and test suite does not produce an error.

ulysses4ever commented 1 day ago

Oh, Agda is a wonderful source of Cabal bugs! Unfortunately, some of them has to do with the Custom build type, which is on life support these days... I wonder if there's a simpler reproducer with Custom...

ulysses4ever commented 1 day ago

Maybe @mpickering has ideas about this issue?

noughtmare commented 1 day ago

You are right. I created a package with two components and a trivial custom-setup and it gives me the same error. I guess custom-setup is just not supported. Perhaps the best immediate course of action is to point that out in the error message.

ulysses4ever commented 1 day ago

Yes, a better error message would be a good improvement!

mpickering commented 1 day ago

You need to build the Setup with a version of the cabal library which supports the multi-repl. I am not sure why this is allowed as there should be a constraint which forces a new enough version of Cabal to be used.

noughtmare commented 1 day ago

Is that something I could do myself? I tried adding this constraint in the custom-setup section:

custom-setup
  setup-depends:
    base, Cabal >=3.12

But that doesn't help.