Skip to content

Bad error message: "Failed to find the GHC version of this Cabal project" #1169

Open
@noughtmare

Description

@noughtmare

Your environment

Which OS do you use: NixOS

Steps to reproduce

  1. Introduce an error in your .cabal file.
  2. Restart HLS

Expected behaviour

The error should be shown. In my case:

Errors encountered when parsing cabal file ./hirane.cabal:

hirane.cabal:27:7: error:
unexpected 'L'
expecting space, comma, white space or end of input

   26 |       Embedded.Hirane.List
   27 |       Language.Hirane.AST
      |       ^

Actual behaviour

It just shows a generic message:

Failed to find the GHC version of this Cabal project. Error when calling cabal exec -v0 -- ghc --print-libdir

Include debug information

Execute in the root of your project the command haskell-language-server-wrapper --debug . and paste the logs here (you can find the executable location here):

Debug output:
No 'hie.yaml' found. Try to discover the project type!
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 2.9.0.0 x86_64 ghc-9.6.6
Current directory: /home/user/haskell/hirane
Operating system: linux
Arguments: ["--debug","."]
Cradle directory: /home/user/haskell/hirane
Cradle type: Cabal

Tool versions found on the $PATH
cabal:          3.12.1.0
stack:          Not found
ghc:            9.6.6


Consulting the cradle to get project GHC version...
2024-11-27T20:54:34.546282Z | Debug | cabal exec -v0 -- ghc --print-libdir
Failed to find the GHC version of this Cabal project.
Error when calling cabal exec -v0 -- ghc --print-libdir

Errors encountered when parsing cabal file ./hirane.cabal:

hirane.cabal:27:7: error:
unexpected 'L'
expecting space, comma, white space or end of input

   26 |       Embedded.Hirane.List
   27 |       Language.Hirane.AST
      |       ^

Paste the contents of extension specific log, you can check instructions about how to find it here

Extension log:
[Info  - 9:56:18 PM] Stopping the server
2024-11-27T20:56:18.337823Z | Info | LSP: received shutdown
[Info  - 9:56:18 PM] Starting the server
2024-11-27T20:56:18.338501Z | Error | Got EOF
No 'hie.yaml' found. Try to discover the project type!
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 2.9.0.0 x86_64 ghc-9.6.6
Current directory: /home/user/haskell/hirane
Operating system: linux
Arguments: ["--lsp"]
Cradle directory: /home/user/haskell/hirane
Cradle type: Cabal

Tool versions found on the $PATH
cabal:          3.12.1.0
stack:          Not found
ghc:            9.6.6


Consulting the cradle to get project GHC version...
2024-11-27T20:56:18.712954Z | Debug | cabal exec -v0 -- ghc --print-libdir
Failed to find the GHC version of this Cabal project.
Error when calling cabal exec -v0 -- ghc --print-libdir

Errors encountered when parsing cabal file ./hirane.cabal:

hirane.cabal:27:7: error:
unexpected 'L'
expecting space, comma, white space or end of input

   26 |       Embedded.Hirane.List
   27 |       Language.Hirane.AST
      |       ^


 2024-11-27T20:56:18.714257Z | Info | Starting server
2024-11-27T20:56:18.716392Z | Error | LSP: no handler for: "initialized"
2024-11-27T20:56:18.716959Z | Debug | LSP: set new config: {
  "checkProject": true,
  "formattingProvider": "fourmolu",
  "ghcupExecutablePath": "",
  "indentationRules": { "enabled": true },
  "logFile": "",
  "manageHLS": "PATH",
  "maxCompletions": 40,
  "metadataURL": "",
  "openDocumentationInHackage": true,
  "openSourceInHackage": true,
  "plugin": {
    "alternateNumberFormat": { "globalOn": true },
    "cabal": {
      "codeActionsOn": true,
      "completionOn": true,
      "diagnosticsOn": true
    },
    "cabal-fmt": { "config": { "path": "cabal-fmt" } },
    "cabal-gild": { "config": { "path": "cabal-gild" } },
    "callHierarchy": { "globalOn": true },
    "changeTypeSignature": { "globalOn": true },
    "class": { "codeActionsOn": true, "codeLensOn": true },
    "eval": {
      "config": { "diff": true, "exception": false },
      "globalOn": true
    },
    "explicit-fields": { "globalOn": true },
    "explicit-fixity": { "globalOn": true },
    "fourmolu": { "config": { "external": false, "path": "fourmolu" } },
    "gadt": { "globalOn": true },
    "ghcide-code-actions-bindings": { "globalOn": true },
    "ghcide-code-actions-fill-holes": { "globalOn": true },
    "ghcide-code-actions-imports-exports": { "globalOn": true },
    "ghcide-code-actions-type-signatures": { "globalOn": true },
    "ghcide-completions": {
      "config": { "autoExtendOn": true, "snippetsOn": true },
      "globalOn": true
    },
    "ghcide-hover-and-symbols": { "hoverOn": true, "symbolsOn": true },
    "ghcide-type-lenses": { "config": { "mode": "always" }, "globalOn": true },
    "hlint": {
      "codeActionsOn": false,
      "config": { "flags": [  ] },
      "diagnosticsOn": false
    },
    "importLens": { "codeActionsOn": true, "codeLensOn": true },
    "moduleName": { "globalOn": true },
    "ormolu": { "config": { "external": false } },
    "overloaded-record-dot": { "globalOn": true },
    "pragmas-completion": { "globalOn": true },
    "pragmas-disable": { "globalOn": true },
    "pragmas-suggest": { "globalOn": true },
    "qualifyImportedNames": { "globalOn": true },
    "rename": { "config": { "crossModule": false }, "globalOn": true },
    "retrie": { "globalOn": true },
    "semanticTokens": {
      "config": {
        "classMethodToken": "method",
        "classToken": "class",
        "dataConstructorToken": "enumMember",
        "functionToken": "function",
        "moduleToken": "namespace",
        "operatorToken": "operator",
        "patternSynonymToken": "macro",
        "recordFieldToken": "property",
        "typeConstructorToken": "enum",
        "typeFamilyToken": "interface",
        "typeSynonymToken": "type",
        "typeVariableToken": "typeParameter",
        "variableToken": "variable"
      },
      "globalOn": false
    },
    "splice": { "globalOn": true },
    "stan": { "globalOn": false }
  },
  "promptBeforeDownloads": "true",
  "releasesDownloadStoragePath": "",
  "releasesURL": "",
  "serverEnvironment": {  },
  "serverExecutablePath": "",
  "serverExtraArgs": "",
  "sessionLoading": "singleComponent",
  "toolchain": {  },
  "trace": { "client": "info", "server": "off" },
  "upgradeGHCup": true
}
2024-11-27T20:56:18.724522Z | Error | LSP: no handler for: "workspace/didChangeConfiguration"
2024-11-27T20:56:18.725072Z | Debug | VFS: opening file:///home/user/haskell/hirane/src/Language/Hirane/AST.hs
2024-11-27T20:56:18.725567Z | Error | LSP: no handler for: "textDocument/didOpen"
2024-11-27T20:56:18.725808Z | Debug | VFS: opening file:///home/user/haskell/hirane/src/Embedded/Hirane/Nat.hs
2024-11-27T20:56:18.726158Z | Error | LSP: no handler for: "textDocument/didOpen"
2024-11-27T20:56:18.726386Z | Debug | VFS: opening file:///home/user/haskell/hirane/src/MyLib.hs
2024-11-27T20:56:18.726679Z | Error | LSP: no handler for: "textDocument/didOpen"
2024-11-27T20:56:18.727043Z | Debug | LSP: set new config: {
  "checkProject": true,
  "formattingProvider": "fourmolu",
  "ghcupExecutablePath": "",
  "indentationRules": { "enabled": true },
  "logFile": "",
  "manageHLS": "PATH",
  "maxCompletions": 40,
  "metadataURL": "",
  "openDocumentationInHackage": true,
  "openSourceInHackage": true,
  "plugin": {
    "alternateNumberFormat": { "globalOn": true },
    "cabal": {
      "codeActionsOn": true,
      "completionOn": true,
      "diagnosticsOn": true
    },
    "cabal-fmt": { "config": { "path": "cabal-fmt" } },
    "cabal-gild": { "config": { "path": "cabal-gild" } },
    "callHierarchy": { "globalOn": true },
    "changeTypeSignature": { "globalOn": true },
    "class": { "codeActionsOn": true, "codeLensOn": true },
    "eval": {
      "config": { "diff": true, "exception": false },
      "globalOn": true
    },
    "explicit-fields": { "globalOn": true },
    "explicit-fixity": { "globalOn": true },
    "fourmolu": { "config": { "external": false, "path": "fourmolu" } },
    "gadt": { "globalOn": true },
    "ghcide-code-actions-bindings": { "globalOn": true },
    "ghcide-code-actions-fill-holes": { "globalOn": true },
    "ghcide-code-actions-imports-exports": { "globalOn": true },
    "ghcide-code-actions-type-signatures": { "globalOn": true },
    "ghcide-completions": {
      "config": { "autoExtendOn": true, "snippetsOn": true },
      "globalOn": true
    },
    "ghcide-hover-and-symbols": { "hoverOn": true, "symbolsOn": true },
    "ghcide-type-lenses": { "config": { "mode": "always" }, "globalOn": true },
    "hlint": {
      "codeActionsOn": false,
      "config": { "flags": [  ] },
      "diagnosticsOn": false
    },
    "importLens": { "codeActionsOn": true, "codeLensOn": true },
    "moduleName": { "globalOn": true },
    "ormolu": { "config": { "external": false } },
    "overloaded-record-dot": { "globalOn": true },
    "pragmas-completion": { "globalOn": true },
    "pragmas-disable": { "globalOn": true },
    "pragmas-suggest": { "globalOn": true },
    "qualifyImportedNames": { "globalOn": true },
    "rename": { "config": { "crossModule": false }, "globalOn": true },
    "retrie": { "globalOn": true },
    "semanticTokens": {
      "config": {
        "classMethodToken": "method",
        "classToken": "class",
        "dataConstructorToken": "enumMember",
        "functionToken": "function",
        "moduleToken": "namespace",
        "operatorToken": "operator",
        "patternSynonymToken": "macro",
        "recordFieldToken": "property",
        "typeConstructorToken": "enum",
        "typeFamilyToken": "interface",
        "typeSynonymToken": "type",
        "typeVariableToken": "typeParameter",
        "variableToken": "variable"
      },
      "globalOn": false
    },
    "splice": { "globalOn": true },
    "stan": { "globalOn": false }
  },
  "promptBeforeDownloads": "true",
  "releasesDownloadStoragePath": "",
  "releasesURL": "",
  "serverEnvironment": {  },
  "serverExecutablePath": "",
  "serverExtraArgs": "",
  "sessionLoading": "singleComponent",
  "toolchain": {  },
  "trace": { "client": "info", "server": "off" },
  "upgradeGHCup": true
}
2024-11-27T20:56:18.734735Z | Error | LSP: no handler for: "workspace/didChangeConfiguration"
2024-11-27T20:56:18.735322Z | Debug | LSP: set new config: {
  "checkProject": true,
  "formattingProvider": "fourmolu",
  "ghcupExecutablePath": "",
  "indentationRules": { "enabled": true },
  "logFile": "",
  "manageHLS": "PATH",
  "maxCompletions": 40,
  "metadataURL": "",
  "openDocumentationInHackage": true,
  "openSourceInHackage": true,
  "plugin": {
    "alternateNumberFormat": { "globalOn": true },
    "cabal": {
      "codeActionsOn": true,
      "completionOn": true,
      "diagnosticsOn": true
    },
    "cabal-fmt": { "config": { "path": "cabal-fmt" } },
    "cabal-gild": { "config": { "path": "cabal-gild" } },
    "callHierarchy": { "globalOn": true },
    "changeTypeSignature": { "globalOn": true },
    "class": { "codeActionsOn": true, "codeLensOn": true },
    "eval": {
      "config": { "diff": true, "exception": false },
      "globalOn": true
    },
    "explicit-fields": { "globalOn": true },
    "explicit-fixity": { "globalOn": true },
    "fourmolu": { "config": { "external": false, "path": "fourmolu" } },
    "gadt": { "globalOn": true },
    "ghcide-code-actions-bindings": { "globalOn": true },
    "ghcide-code-actions-fill-holes": { "globalOn": true },
    "ghcide-code-actions-imports-exports": { "globalOn": true },
    "ghcide-code-actions-type-signatures": { "globalOn": true },
    "ghcide-completions": {
      "config": { "autoExtendOn": true, "snippetsOn": true },
      "globalOn": true
    },
    "ghcide-hover-and-symbols": { "hoverOn": true, "symbolsOn": true },
    "ghcide-type-lenses": { "config": { "mode": "always" }, "globalOn": true },
    "hlint": {
      "codeActionsOn": false,
      "config": { "flags": [  ] },
      "diagnosticsOn": false
    },
    "importLens": { "codeActionsOn": true, "codeLensOn": true },
    "moduleName": { "globalOn": true },
    "ormolu": { "config": { "external": false } },
    "overloaded-record-dot": { "globalOn": true },
    "pragmas-completion": { "globalOn": true },
    "pragmas-disable": { "globalOn": true },
    "pragmas-suggest": { "globalOn": true },
    "qualifyImportedNames": { "globalOn": true },
    "rename": { "config": { "crossModule": false }, "globalOn": true },
    "retrie": { "globalOn": true },
    "semanticTokens": {
      "config": {
        "classMethodToken": "method",
        "classToken": "class",
        "dataConstructorToken": "enumMember",
        "functionToken": "function",
        "moduleToken": "namespace",
        "operatorToken": "operator",
        "patternSynonymToken": "macro",
        "recordFieldToken": "property",
        "typeConstructorToken": "enum",
        "typeFamilyToken": "interface",
        "typeSynonymToken": "type",
        "typeVariableToken": "typeParameter",
        "variableToken": "variable"
      },
      "globalOn": false
    },
    "splice": { "globalOn": true },
    "stan": { "globalOn": false }
  },
  "promptBeforeDownloads": "true",
  "releasesDownloadStoragePath": "",
  "releasesURL": "",
  "serverEnvironment": {  },
  "serverExecutablePath": "",
  "serverExtraArgs": "",
  "sessionLoading": "singleComponent",
  "toolchain": {  },
  "trace": { "client": "info", "server": "off" },
  "upgradeGHCup": true
}
2024-11-27T20:56:18.745544Z | Debug | LSP: set new config: {
  "checkProject": true,
  "formattingProvider": "fourmolu",
  "ghcupExecutablePath": "",
  "indentationRules": { "enabled": true },
  "logFile": "",
  "manageHLS": "PATH",
  "maxCompletions": 40,
  "metadataURL": "",
  "openDocumentationInHackage": true,
  "openSourceInHackage": true,
  "plugin": {
    "alternateNumberFormat": { "globalOn": true },
    "cabal": {
      "codeActionsOn": true,
      "completionOn": true,
      "diagnosticsOn": true
    },
    "cabal-fmt": { "config": { "path": "cabal-fmt" } },
    "cabal-gild": { "config": { "path": "cabal-gild" } },
    "callHierarchy": { "globalOn": true },
    "changeTypeSignature": { "globalOn": true },
    "class": { "codeActionsOn": true, "codeLensOn": true },
    "eval": {
      "config": { "diff": true, "exception": false },
      "globalOn": true
    },
    "explicit-fields": { "globalOn": true },
    "explicit-fixity": { "globalOn": true },
    "fourmolu": { "config": { "external": false, "path": "fourmolu" } },
    "gadt": { "globalOn": true },
    "ghcide-code-actions-bindings": { "globalOn": true },
    "ghcide-code-actions-fill-holes": { "globalOn": true },
    "ghcide-code-actions-imports-exports": { "globalOn": true },
    "ghcide-code-actions-type-signatures": { "globalOn": true },
    "ghcide-completions": {
      "config": { "autoExtendOn": true, "snippetsOn": true },
      "globalOn": true
    },
    "ghcide-hover-and-symbols": { "hoverOn": true, "symbolsOn": true },
    "ghcide-type-lenses": { "config": { "mode": "always" }, "globalOn": true },
    "hlint": {
      "codeActionsOn": false,
      "config": { "flags": [  ] },
      "diagnosticsOn": false
    },
    "importLens": { "codeActionsOn": true, "codeLensOn": true },
    "moduleName": { "globalOn": true },
    "ormolu": { "config": { "external": false } },
    "overloaded-record-dot": { "globalOn": true },
    "pragmas-completion": { "globalOn": true },
    "pragmas-disable": { "globalOn": true },
    "pragmas-suggest": { "globalOn": true },
    "qualifyImportedNames": { "globalOn": true },
    "rename": { "config": { "crossModule": false }, "globalOn": true },
    "retrie": { "globalOn": true },
    "semanticTokens": {
      "config": {
        "classMethodToken": "method",
        "classToken": "class",
        "dataConstructorToken": "enumMember",
        "functionToken": "function",
        "moduleToken": "namespace",
        "operatorToken": "operator",
        "patternSynonymToken": "macro",
        "recordFieldToken": "property",
        "typeConstructorToken": "enum",
        "typeFamilyToken": "interface",
        "typeSynonymToken": "type",
        "typeVariableToken": "typeParameter",
        "variableToken": "variable"
      },
      "globalOn": false
    },
    "splice": { "globalOn": true },
    "stan": { "globalOn": false }
  },
  "promptBeforeDownloads": "true",
  "releasesDownloadStoragePath": "",
  "releasesURL": "",
  "serverEnvironment": {  },
  "serverExecutablePath": "",
  "serverExtraArgs": "",
  "sessionLoading": "singleComponent",
  "toolchain": {  },
  "trace": { "client": "info", "server": "off" },
  "upgradeGHCup": true
}
2024-11-27T20:56:18.754059Z | Debug | LSP: set new config: {
  "checkProject": true,
  "formattingProvider": "fourmolu",
  "ghcupExecutablePath": "",
  "indentationRules": { "enabled": true },
  "logFile": "",
  "manageHLS": "PATH",
  "maxCompletions": 40,
  "metadataURL": "",
  "openDocumentationInHackage": true,
  "openSourceInHackage": true,
  "plugin": {
    "alternateNumberFormat": { "globalOn": true },
    "cabal": {
      "codeActionsOn": true,
      "completionOn": true,
      "diagnosticsOn": true
    },
    "cabal-fmt": { "config": { "path": "cabal-fmt" } },
    "cabal-gild": { "config": { "path": "cabal-gild" } },
    "callHierarchy": { "globalOn": true },
    "changeTypeSignature": { "globalOn": true },
    "class": { "codeActionsOn": true, "codeLensOn": true },
    "eval": {
      "config": { "diff": true, "exception": false },
      "globalOn": true
    },
    "explicit-fields": { "globalOn": true },
    "explicit-fixity": { "globalOn": true },
    "fourmolu": { "config": { "external": false, "path": "fourmolu" } },
    "gadt": { "globalOn": true },
    "ghcide-code-actions-bindings": { "globalOn": true },
    "ghcide-code-actions-fill-holes": { "globalOn": true },
    "ghcide-code-actions-imports-exports": { "globalOn": true },
    "ghcide-code-actions-type-signatures": { "globalOn": true },
    "ghcide-completions": {
      "config": { "autoExtendOn": true, "snippetsOn": true },
      "globalOn": true
    },
    "ghcide-hover-and-symbols": { "hoverOn": true, "symbolsOn": true },
    "ghcide-type-lenses": { "config": { "mode": "always" }, "globalOn": true },
    "hlint": {
      "codeActionsOn": false,
      "config": { "flags": [  ] },
      "diagnosticsOn": false
    },
    "importLens": { "codeActionsOn": true, "codeLensOn": true },
    "moduleName": { "globalOn": true },
    "ormolu": { "config": { "external": false } },
    "overloaded-record-dot": { "globalOn": true },
    "pragmas-completion": { "globalOn": true },
    "pragmas-disable": { "globalOn": true },
    "pragmas-suggest": { "globalOn": true },
    "qualifyImportedNames": { "globalOn": true },
    "rename": { "config": { "crossModule": false }, "globalOn": true },
    "retrie": { "globalOn": true },
    "semanticTokens": {
      "config": {
        "classMethodToken": "method",
        "classToken": "class",
        "dataConstructorToken": "enumMember",
        "functionToken": "function",
        "moduleToken": "namespace",
        "operatorToken": "operator",
        "patternSynonymToken": "macro",
        "recordFieldToken": "property",
        "typeConstructorToken": "enum",
        "typeFamilyToken": "interface",
        "typeSynonymToken": "type",
        "typeVariableToken": "typeParameter",
        "variableToken": "variable"
      },
      "globalOn": false
    },
    "splice": { "globalOn": true },
    "stan": { "globalOn": false }
  },
  "promptBeforeDownloads": "true",
  "releasesDownloadStoragePath": "",
  "releasesURL": "",
  "serverEnvironment": {  },
  "serverExecutablePath": "",
  "serverExtraArgs": "",
  "sessionLoading": "singleComponent",
  "toolchain": {  },
  "trace": { "client": "info", "server": "off" },
  "upgradeGHCup": true
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions