haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.71k stars 367 forks source link

Error using multiple home component with cabal 3.12 prerelease in HLS Repo #4196

Closed soulomoon closed 6 months ago

soulomoon commented 6 months ago

Using cabal 3.12 prerelease and set up multiple home component.

I am getting this error in hls

Failed to run ["cabal","v2-repl","--keep-temp-files","--enable-multi-repl","/Volumes/src/tmp/haskell-language-server/ghcide/exe/Arguments.hs"] in directory "/Volumes/src/tmp/haskell-language-server". Consult the logs for full command and error.
Failed command: cabal --builddir=/Users/ares/.cache/hie-bios/dist-haskell-language-server-8b3fdc867a093d1a8b96d1c678b3d1e7 v2-repl --with-compiler /Users/ares/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /Users/ares/.cache/hie-bios/ghc-pkg-1b82796610925ca7ef8e1313dec68239 --keep-temp-files --enable-multi-repl /Volumes/src/tmp/haskell-language-server/ghcide/exe/Arguments.hs
Resolving dependencies...

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

Process Environment:
HIE_BIOS_GHC: /Users/ares/.ghcup/ghc/9.8.2/lib/ghc-9.8.2/bin/ghc-9.8.2
HIE_BIOS_GHC_ARGS: -B/Users/ares/.ghcup/ghc/9.8.2/lib/ghc-9.8.2/lib
cradle
"DAML": Unknown word.cSpell
soulomoon commented 6 months ago

It seems cabal v2-repl --keep-temp-files --enable-multi-repl /Volumes/src/tmp/haskell-language-server/ghcide/exe/Arguments.hs fails on hls code base

and it is fine if we use cabal v2-repl /Volumes/src/tmp/haskell-language-server/ghcide/exe/Arguments.hs

soulomoon commented 6 months ago

Probably this issue should be transferred to cabal?

A version mismatch, it is expected?🤔 The same cabal build the project just fine.

Bodigrim commented 6 months ago

Looks like https://github.com/haskell/cabal/issues/9632, try the same workaround in cabal.project?..

soulomoon commented 6 months ago

Thanks, the workaround does the magic @Bodigrim Of reviewing what the real issue is

❯ cabal v2-repl --keep-temp-files --enable-multi-repl /Volumes/src/tmp/haskell-language-server/ghcide/exe/Arguments.hs
...
Installing   ghc-paths-0.1.0.12 (all, legacy fallback: build-type is Custom)
Completed    ghc-paths-0.1.0.12 (all, legacy fallback: build-type is Custom)
Error: [Cabal-7125]
Failed to build entropy-0.4.1.10 (which is required by exe:ghcide from ghcide-2.7.0.0). The failure occurred during the configure step. The exception was:
  /Users/ares/.cabal/logs/ghc-9.8.2/ntrpy-0.4.1.10-1528a9b1.log: withFile: user error (Error: cabal: '/Users/ares/.ghcup/bin/ghc' exited with an error:

/Volumes/src/tmp/haskell-language-server/dist-newstyle/tmp/src-97692/entropy-0.4.1.10/dist/setup/setup.hs:111:23:
error: [GHC-83865]
• Couldn't match type: Maybe
(Distribution.Utils.Path.SymbolicPath
Distribution.Utils.Path.CWD
(Distribution.Utils.Path.Dir Distribution.Utils.Path.Pkg))
with: [Char]
Expected: Verbosity -> FilePath -> [String] -> IO ExitCode
Actual: Verbosity
-> Maybe
(Distribution.Utils.Path.SymbolicPath
Distribution.Utils.Path.CWD
(Distribution.Utils.Path.Dir Distribution.Utils.Path.Pkg))
-> FilePath
-> [String]
-> IO ExitCode
• Probable cause: ‘rawSystemExitCode’ is applied to too few arguments
In the expression: rawSystemExitCode
In an equation for ‘myRawSystemExitCode’:
myRawSystemExitCode = rawSystemExitCode
|
111 | myRawSystemExitCode = rawSystemExitCode
| ^^^^^^^^^^^^^^^^^
)
soulomoon commented 6 months ago

Turn out this workaround would need the pin the extact cabal version to 3.12.0+0 that shipped with the cabal-install I use https://gitlab.haskell.org/haskell/cabal/-/jobs/1848815.

allow-newer:
  *:Cabal,
  *:Cabal-syntax

source-repository-package
    type: git
    location: https://github.com/haskell/cabal.git
    subdir: Cabal Cabal-syntax
    tag : 3.12.0+0
Mikolaj commented 6 months ago

@soulomoon: why is the official tag 3.12.0.0 not enough? It should be. What tag/branch have you been using that did not work with the workaround?

soulomoon commented 6 months ago

@soulomoon: why is the official tag 3.12.0.0 not enough? It should be. What tag/branch have you been using that did not work with the workaround?

sorry for not stating it clear, not pin to a tag is not enough, pin to tag 3.12.0.0 fix that.

Mikolaj commented 6 months ago

Cool! Thank you very much for the confirmation.

soulomoon commented 6 months ago

Another error, it is fine if I repl each file, but not when it come togather ==== update You need to cd to ghcide to observe this. Works fine

cabal v2-repl --enable-multi-repl /Volumes/src/soulomoonHLS/ghcide/test/src/Development/IDE/Test.hs
cabal v2-repl --enable-multi-repl /Volumes/src/soulomoonHLS/ghcide/test/exe/DependentFileTest.hs

But not

❯ cabal v2-repl --enable-multi-repl /Volumes/src/soulomoonHLS/ghcide/test/src/Development/IDE/Test.hs /Volumes/src/soulomoonHLS/ghcide/test/exe/DependentFileTest.hs

Build profile: -w ghc-9.8.2 -O1
In order, the following will be built (use -v for more details):
 - ghcide-2.7.0.0 (interactive) (lib:ghcide-test-utils) (first run)
 - haskell-language-server-2.7.0.0 (interactive) (test:ghcide-tests) (configuration changed)
Preprocessing library 'ghcide-test-utils' for ghcide-2.7.0.0...
Configuring test suite 'ghcide-tests' for haskell-language-server-2.7.0.0...
Error:
    Dependency on unbuildable library 'ghcide-test-utils' from ghcide

Error: [Cabal-7125]
Failed to build test:ghcide-tests from haskell-language-server-2.7.0.0. The failure occurred during the configure step.
soulomoon commented 6 months ago

maybe when we repl both, we pick up some package that have a setup.hs mismatching Cabal with

 subdir: Cabal Cabal-syntax
    tag : 3.12.0+0
soulomoon commented 6 months ago

It is a dependency problem, I opened new issue to push for the update for the dependency instead https://github.com/haskell/haskell-language-server/issues/4219