failed to parse result of calling cabal (better error message)
I get in Problems the message failed to parse result of calling cabal which is hinting an internal problem. The cause was most mundane: the library in the project did not compile and in consequence the executable could not compile - strange enough, the other executable did not produce any error.
Your environment
Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:
haskell-language-server-wrapper --probe-tools
haskell-language-server version: 1.1.0.0 (GHC: 8.10.4) (PATH: /home/frank/.ghcup/bin/haskell-language-server-wrapper-1.1.0) (GIT hash: f1c096927186a93d8e3ccd4fe8385cc1b070350b)
Tool versions found on the $PATH
cabal: 3.4.0.0
stack: 2.5.1
ghc: 8.10.4
Which OS do you use: debian bullseye AMD64
Which lsp-client do you use: vs code
Describe your project (alternative: link to the project):
two executables, a library,
Steps to reproduce
I am not certain that this can be reproduced - I have not seen it in other similar cases.
Expected behaviour
I expect a reasonable error message
Actual behaviour
{
"resource": "/home/frank/Workspace11/ssg/app/ssgBake.hs",
"owner": "Haskell (ssg)",
"severity": 8,
"message": "Failed to parse result of calling cabal\nBuild profile: -w ghc-8.10.4 -O1\nIn order, the following will be built (use -v for more details):\n - ssg-0.0.4.2 (lib) (file src/Uniform/Docrep.hs changed)\n - ssg-0.0.4.2 (exe:ssgbake) (configuration changed)\nPreprocessing library for ssg-0.0.4.2..\nBuilding library for ssg-0.0.4.2..\n[10 of 23] Compiling Uniform.Docrep ( src/Uniform/Docrep.hs, /home/frank/.cache/hie-bios/dist-ssg-ccec0eed33d4ea624add0f1a2f74e2f0/build/x86_64-linux/ghc-8.10.4/ssg-0.0.4.2/build/Uniform/Docrep.o, /home/frank/.cache/hie-bios/dist-ssg-ccec0eed33d4ea624add0f1a2f74e2f0/build/x86_64-linux/ghc-8.10.4/ssg-0.0.4.2/build/Uniform/Docrep.dyn_o )\n[12 of 23] Compiling Uniform.Pandoc ( src/Uniform/Pandoc.hs, /home/frank/.cache/hie-bios/dist-ssg-ccec0eed33d4ea624add0f1a2f74e2f0/build/x86_64-linux/ghc-8.10.4/ssg-0.0.4.2/build/Uniform/Pandoc.o, /home/frank/.cache/hie-bios/dist-ssg-ccec0eed33d4ea624add0f1a2f74e2f0/build/x86_64-linux/ghc-8.10.4/ssg-0.0.4.2/build/Uniform/Pandoc.dyn_o ) [Uniform.Docrep changed]\n[14 of 23] Compiling Lib.MetaPage ( src/Lib/MetaPage.hs, /home/frank/.cache/hie-bios/dist-ssg-ccec0eed33d4ea624add0f1a2f74e2f0/build/x86_64-linux/ghc-8.10.4/ssg-0.0.4.2/build/Lib/MetaPage.o, /home/frank/.cache/hie-bios/dist-ssg-ccec0eed33d4ea624add0f1a2f74e2f0/build/x86_64-linux/ghc-8.10.4/ssg-0.0.4.2/build/Lib/MetaPage.dyn_o )\n\n\nsrc/Lib/MetaPage.hs:33:37: error:\n Not in scope: type constructor or class ‘DocLanguage’\n |\n33 | , dyLang :: DocLanguage\n | ^^^^^^^^^^^\n\nsrc/Lib/MetaPage.hs:48:44: error:\n Not in scope: type constructor or class ‘IndexEntry’\n |\n48 | , dyDirEntries :: [IndexEntry]\n | ^^^^^^^^^^\n\nsrc/Lib/MetaPage.hs:49:45: error:\n Not in scope: type constructor or class ‘IndexEntry’\n |\n49 | , dyFileEntries :: [IndexEntry]\n | ^^^^^^^^^^\n\nsrc/Lib/MetaPage.hs:70:10: error:\n Not in scope: type constructor or class ‘Default’\n |\n70 | instance Default MetaPage where\n | ^^^^^^^\n\nsrc/Lib/MetaPage.hs:87:19: error:\n Not in scope: type constructor or class ‘Options’\n |\n87 | docyamlOptions :: Options\n | ^^^^^^^\n\nsrc/Lib/MetaPage.hs:90:10: error:\n Not in scope: ‘fieldLabelModifier’\n |\n90 | {fieldLabelModifier = t2s . toLowerStart . s2t . drop 2 }\n | ^^^^^^^^^^^^^^^^^^\n\nsrc/Lib/MetaPage.hs:92:10: error:\n Not in scope: type constructor or class ‘ToJSON’\n |\n92 | instance ToJSON MetaPage where\n | ^^^^^^\n\nsrc/Lib/MetaPage.hs:95:10: error:\n Not in scope: type constructor or class ‘FromJSON’\n |\n95 | instance FromJSON MetaPage where\n | ^^^^^^^^\n\nsrc/Lib/MetaPage.hs:104:16: error:\n Not in scope: data constructor ‘Object’\n |\n104 | parseJSONyaml (Object o) = -- withObject \"person\" $ \\o -> \n | ^^^^^^\n\nsrc/Lib/MetaPage.hs:125:12: error:\n Illegal `..' in record construction\n Use RecordWildCards to permit this\n |\n125 | return MetaPage { .. }\n | ^^^^^^^^^^^^^^^\n\nsrc/Lib/MetaPage.hs:127:66: error:\n Not in scope: type constructor or class ‘Value’\n |\n127 | checkDocrep1 :: Path Abs Dir -> Path Abs Dir -> Path Abs File -> Value -> ErrIO MetaPage\n | ^^^^^\ncabal: Failed to build ssg-0.0.4.2 (which is required by exe:ssgbake from\nssg-0.0.4.2).\n\n\n\n",
"source": "cradle",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 2,
"endColumn": 1
}
The message 'failed ..' persists even after the code compile ok. It disappeared after I run the executable.
If this is more than a fluke I can probably give more information and try to reproduce.
Hi, thanks for the bug report and agree the error message could be improved. However cabal can fail for several different reasons (and not always its error messages are too good)
I expect a reasonable error message
It would be helpful to know some approximation to the message you would expect.
Perhaps something
- indicating that there was an error produced by compiling the module
- analysis failed and therefore the full output from the compiler is given if it need be compacted to one line: Compilation of XX failed, but analysis of error not successful.
When HLS works, it is really helpful.
I think it would be a general improvement showing the error message produced by CradleLoadResult as it at least contains the command that failed and users could just execute it themselves for seeing the original error.
yeah, we could even add the suggestion, with the cli invocation if possible
Perhaps something along the lines:
- indicating that there was an error produced by compiling the module
- analysis failed and therefore the full output from the compiler is given if it need be compacted to one line: Compilation of XX failed, but analysis of error not successful.
Including the CradleLoadResult might be helpful for users to understand somewhat more what goes on behind the scence.
When HLS works, it is really helpful.
I see the error failed to parse... now with some regularity whenever I move files from a subdir in src (i.e. moving from one library to another one) or change the filenames. Details of the error message seem to include the 'old' names, which I take as indication that some cache is not updated/invalidated in such cases.
Hope this help!
I could only get rid of the error message with restarting the vscode - I would guess that vscode keeps somewhere inodes (which are still valid after moving a file or deleting=moving to trash).
I got the same problem, the error message is scary even if it only means “local library depndency target didn’t compile”.
It will happen during normal development, basically any time you open Main.hs while you changed something in the Lib.hs and it doesn’t yet compile.
It will also stay around indefinitely, even after fixing Lib.hs errors.
I'm getting the same error even though my project seems to build just fine using cabal. Here is the complete message:
Failed to parse result of calling cabal Failed command: cabal --builddir=/home/ron/.cache/hie-bios/dist-project-91b19dd5a92e57027ae37813b1bd8241 v2-repl --with-compiler /home/ron/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/ron/.cache/hie-bios/ghc-pkg-c0db172baf4a650f68d1c6bc0f2b4955 /home/ron/paav/project/src/Analysis.hs Build profile: -w ghc-9.10.1 -O1 In order, the following will be built (use -v for more details): - analysis-0.1.0.0 (interactive) (lib) (configuration changed) Configuring library for analysis-0.1.0.0... Preprocessing library for analysis-0.1.0.0... GHCi, version 9.10.1: https://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/ron/.ghc/ghci.conf Loaded GHCi configuration from /home/ron/paav/project/.ghci [1 of 4] Compiling Analysis.Types ( src/Analysis/Types.hs, interpreted ) [2 of 4] Compiling Analysis.Parser ( src/Analysis/Parser.hs, interpreted ) [3 of 4] Compiling Analysis ( src/Analysis.hs, interpreted ) [4 of 4] Compiling Paths_analysis ( /home/ron/.cache/hie-bios/dist-project-91b19dd5a92e57027ae37813b1bd8241/build/x86_64-linux/ghc-9.10.1/analysis-0.1.0.0/build/autogen/Paths_analysis.hs, interpreted ) Ok, four modules loaded. ghci> Leaving GHCi.
Process Environment: HIE_BIOS_GHC: /home/ron/.ghcup/ghc/9.10.1/lib/ghc-9.10.1/bin/ghc-9.10.1 HIE_BIOS_GHC_ARGS: -B/home/ron/.ghcup/ghc/9.10.1/lib/ghc-9.10.1/lib
Tool version summary from GHCup:
✔✔ ghc 9.6.7 recommended,base-4.18.3.0 hls-powered ✔✔ cabal 3.12.1.0 recommended ✔✔ hls 2.10.0.0 recommended ✔✔ stack 3.3.1 recommended ✔✔ ghcup 0.1.50.2 latest,recommended
Here is one more piece of information you may find useful, from the log:
2025-07-30T19:50:54.470607Z | Debug | Session loading result: Left [CradleError {cradleErrorDependencies = ["analysis.cabal","cabal.project","cabal.project.local"], cradleErrorExitCode = ExitSuccess, cradleErrorStderr = ["Failed to parse result of calling cabal","Failed command: cabal --builddir=/home/ron/.cache/hie-bios/dist-project-91b19dd5a92e57027ae37813b1bd8241 v2-repl --with-compiler /home/ron/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/ron/.cache/hie-bios/ghc-pkg-c0db172baf4a650f68d1c6bc0f2b4955 /home/ron/paav/project/src/Analysis.hs","Build profile: -w ghc-9.10.1 -O1\nIn order, the following will be built (use -v for more details):\n - analysis-0.1.0.0 (interactive) (lib) (configuration changed)\nConfiguring library for analysis-0.1.0.0...\nPreprocessing library for analysis-0.1.0.0...\nGHCi, version 9.10.1: https://www.haskell.org/ghc/ :? for help\nLoaded GHCi configuration from /home/ron/.ghc/ghci.conf\nLoaded GHCi configuration from /home/ron/paav/project/.ghci\n[1 of 4] Compiling Analysis.Types ( src/Analysis/Types.hs, interpreted )\n[2 of 4] Compiling Analysis.Parser ( src/Analysis/Parser.hs, interpreted )\n[3 of 4] Compiling Analysis ( src/Analysis.hs, interpreted )\n[4 of 4] Compiling Paths_analysis ( /home/ron/.cache/hie-bios/dist-project-91b19dd5a92e57027ae37813b1bd8241/build/x86_64-linux/ghc-9.10.1/analysis-0.1.0.0/build/autogen/Paths_analysis.hs, interpreted )\nOk, four modules loaded.\nghci> Leaving GHCi.\n","","","Process Environment:","HIE_BIOS_GHC: /home/ron/.ghcup/ghc/9.10.1/lib/ghc-9.10.1/bin/ghc-9.10.1","HIE_BIOS_GHC_ARGS: -B/home/ron/.ghcup/ghc/9.10.1/lib/ghc-9.10.1/lib"]}]
Hi, thank you for the bug report! This is indeed a completely useless error message :)
How did you obtain the error message? Do you, by any chance have cabal-3.16 installed?
Hi, thank you for the bug report! This is indeed a completely useless error message :)
How did you obtain the error message? Do you, by any chance have
cabal-3.16installed?
I have it installed in GHCup, but it's not the selected version.
Here is the output from haskell-language-server-wrapper --probe-tools. By the way, I have no idea why and how it chooses GHC 9.10.1. I did try to use this version at some point but then I changed it to 9.6.7.
ron@DESKTOP-*:~/paav/project$ haskell-language-server-wrapper --probe-tools haskell-language-server version: 2.10.0.0 (GHC: 9.10.1) (PATH: /home/ron/.ghcup/hls/2.10.0.0/lib/haskell-language-server-2.10.0.0/bin/haskell-language-server-wrapper) Tool versions found on the $PATH cabal: 3.12.1.0 stack: 3.3.1 ghc: 9.6.7
Tool versions in your project 2025-07-31T08:01:32.599022Z | Debug | cabal exec -v0 -- ghc --print-libdir 2025-07-31T08:01:33.397119Z | Debug | cabal exec -v0 -- ghc -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath) 2025-07-31T08:01:35.281891Z | Debug | cabal --builddir=/home/ron/.cache/hie-bios/dist-project-91b19dd5a92e57027ae37813b1bd8241 v2-exec --with-compiler /home/ron/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/ron/.cache/hie-bios/ghc-pkg-cda1d160dfea1488d60b070678e51d9b ghc -v0 -- --numeric-version Environment Variables HIE_BIOS_GHC: /home/ron/.ghcup/ghc/9.6.7/lib/ghc-9.6.7/bin/ghc-9.6.7 HIE_BIOS_GHC_ARGS: -B/home/ron/.ghcup/ghc/9.6.7/lib/ghc-9.6.7/lib ghc: 9.6.7
If you use vscode-haskell and VSCode, you might be running into this issue: https://github.com/haskell/vscode-haskell/issues/1273