OK, I keep getting HLS errors even though cabal builds fine.
Environment:
- OS: Windows 10 Pro
- GHC: 9.6.7
- Cabal: 3.12.1.0 I'm on Windows 10 Pro Education, using GHC 9.6.7, and cabal 3.12.1.0
I'm sharing my attempts here, but if you can solve this at any stage, feel free to skip the rest of my question.
Attempt 1: Cabal Cradle
Initially, I used a standard hie.yaml:
cradle:
cabal:
component: "executable:rgit"
This failed with a wrapper error. It seems haskell-language-server-wrapper fails to load basic modules like System.Directory or System.Process in the internal scripts it generates. Full Log of Cabal Failure.
Attempt 2: Direct Cradle (Manual Arguments)
To bypass the wrapper issue, I tried a direct cradle. I manually listed the packages found in my .cabal file:
cradle:
direct:
arguments:
- "-package"
- "bytestring"
- "-package"
- "text"
# ... other packages ...
- "Rgit.hs"
This allowed HLS to start, but resulted in a version mismatch error in the VS Code problems tab:
• Couldn't match type ‘BS.ByteString’
with ‘bytestring-0.11.5.4:Data.ByteString.Internal.Type.ByteString’
Expected: bytestring-0.11.5.4:Data.ByteString.Internal.Type.ByteString
-> Data.Text.Internal.Text
Actual: BS.ByteString -> Data.Text.Internal.Text
NB: ‘bytestring-0.11.5.4:Data.ByteString.Internal.Type.ByteString’
is defined in ‘Data.ByteString.Internal.Type’
in package ‘bytestring-0.11.5.4’
‘BS.ByteString’
is defined in ‘Data.ByteString.Internal.Type’
in package ‘bytestring-0.12.2.0’
• In the second argument of ‘(.)’, namely ‘decodeUtf8’
In the second argument of ‘(.)’, namely ‘Hash . decodeUtf8’
In the first argument of ‘($)’, namely ‘pure . Hash . decodeUtf8’
It appears HLS is seeing two different versions of bytestring (0.11.5.4 and 0.12.2.0). Full Log of Type Mismatch.
Attempt 3: Specific Versions & Package DB
I tried specifying the version (-package bytestring-0.11.5.4) and even adding the dist-newstyle package-db path, but this led to "Ambiguous module name" errors because both versions remained visible.
My Question: How can I force HLS to use the exact package environment/versions that Cabal is using on Windows, without it defaulting to a different version from the global/user DB and causing these type mismatches?