infinisil/all-hies

Question: how can I use 1.0 with cabal v1-style mode?

tscholak opened this issue · 5 comments

I'm have been using hie with cabal 2.4 and v1-style builds on nix for quite some time without issue. recently, however, it stopped working, and I never found out why.
Today I updated to hie 1.0 and cabal-install 3, and hie insists to use new-/v2-style builds that my project does not support. All the dependencies are fulfilled by nix in a specific way, and cabal should just use those.
How do I tell hie to use cabal in v1 mode?

ok, I've been able to make some progress by putting a hie.yaml with the following content in the folder of the library:

cradle:
  cabal:
    - path: "./src"
      component: "lib:hasktorch"

this seems to have the desired effect. cabal is not using the cabal.project file in the repo root and does not complain about missing trivial dependencies as it would if I used cabal v2-configure.

However, hie does not work. Here's some debug output:

2020-01-12 17:07:06.889242 [ThreadId 4] - Run entered for HIE(hie-8.6.5) Version 1.0.0.0 x86_64 ghc-8.6.5
2020-01-12 17:07:06.890076 [ThreadId 4] - Operating as a LSP server on stdio
2020-01-12 17:07:06.890124 [ThreadId 4] - Current directory:/Users/tscholak/Projects/thirdParty/hasktorch/hasktorch
2020-01-12 17:07:06.890162 [ThreadId 4] - Operating system:darwin
2020-01-12 17:07:06.890197 [ThreadId 4] - args:["-l","hie.log","-d","--vomit","--lsp"]
2020-01-12 17:07:06.890255 [ThreadId 4] - Enabling verbose mode for hie-bios. This option currently doesn't do anything.
2020-01-12 17:07:06.890375 [ThreadId 4] -




haskell-lsp:Starting up server ...
2020-01-12 17:07:06.890871 [ThreadId 4] - ---> {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":48973,"clientInfo":{"name":"vscode","version":"1.41.1"},"rootPath":"/Users/tscholak/Projects/thirdParty/hasktorch/hasktorch","rootUri":"file:///Users/tscholak/Projects/thirdParty/hasktorch/hasktorch","capabilities":{"workspace":{"applyEdit":true,"workspaceEdit":{"documentChanges":true,"resourceOperations":["create","rename","delete"],"failureHandling":"textOnlyTransactional"},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true},"symbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}},"executeCommand":{"dynamicRegistration":true},"configuration":true,"workspaceFolders":true},"textDocument":{"publishDiagnostics":{"relatedInformation":true,"tagSupport":{"valueSet":[1,2]}},"synchronization":{"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true,"didSave":true},"completion":{"dynamicRegistration":true,"contextSupport":true,"completionItem":{"snippetSupport":true,"commitCharactersSupport":true,"documentationFormat":["markdown","plaintext"],"deprecatedSupport":true,"preselectSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]}},"hover":{"dynamicRegistration":true,"contentFormat":["markdown","plaintext"]},"signatureHelp":{"dynamicRegistration":true,"signatureInformation":{"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}},"contextSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"references":{"dynamicRegistration":true},"documentHighlight":{"dynamicRegistration":true},"documentSymbol":{"dynamicRegistration":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"hierarchicalDocumentSymbolSupport":true},"codeAction":{"dynamicRegistration":true,"isPreferredSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"codeLens":{"dynamicRegistration":true},"formatting":{"dynamicRegistration":true},"rangeFormatting":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"prepareSupport":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"colorProvider":{"dynamicRegistration":true},"foldingRange":{"dynamicRegistration":true,"rangeLimit":5000,"lineFoldingOnly":true},"declaration":{"dynamicRegistration":true,"linkSupport":true},"selectionRange":{"dynamicRegistration":true},"callHierarchy":{"dynamicRegistration":true}},"window":{"workDoneProgress":true}},"trace":"off","workspaceFolders":[{"uri":"file:///Users/tscholak/Projects/thirdParty/hasktorch/hasktorch","name":"hasktorch"}]}}
2020-01-12 17:07:06.892053 [ThreadId 4] - haskell-lsp:initializeRequestHandler: setting current dir to project root:/Users/tscholak/Projects/thirdParty/hasktorch/hasktorch
2020-01-12 17:07:06.892298 [ThreadId 4] - Dummy Cradle file result: /Users/tscholak/Projects/thirdParty/hasktorch/hasktorch/File.hs
2020-01-12 17:07:06.892478 [ThreadId 4] - Found "/Users/tscholak/Projects/thirdParty/hasktorch/hasktorch/hie.yaml" for "/Users/tscholak/Projects/thirdParty/hasktorch/hasktorch/File.hs"
2020-01-12 17:07:06.89839 [ThreadId 4] - Module "/Users/tscholak/Projects/thirdParty/hasktorch/hasktorch/File.hs" is loaded by Cradle: Cradle {cradleRootDir = "/Users/tscholak/Projects/thirdParty/hasktorch/hasktorch", cradleOptsProg = CradleAction: multi}
2020-01-12 17:07:06.937547 [ThreadId 4] - Use Plain GHC
2020-01-12 17:07:07.030108 [ThreadId 4] - GHC Output: "Just "8.6.5""
2020-01-12 17:07:07.032728 [ThreadId 9] - Use Plain GHC
2020-01-12 17:07:07.033358 [ThreadId 10] - ****** reactor: top of loop
2020-01-12 17:07:07.034599 [ThreadId 5] - <--2--{"result":{"capabilities":{"typeDefinitionProvider":true,"foldingRangeProvider":false,"textDocumentSync":{"openClose":true,"change":2,"willSave":false,"willSaveWaitUntil":false,"save":{"includeText":false}},"workspace":{},"implementationProvider":true,"documentRangeFormattingProvider":true,"documentHighlightProvider":true,"executeCommandProvider":{"commands":["50097:applyrefact:applyOne","50097:applyrefact:applyAll","50097:generic:type","50097:ghcmod:check","50097:ghcmod:type","50097:ghcmod:casesplit","50097:hsimport:import","50097:package:add","50097:pragmas:addPragma"]},"renameProvider":false,"colorProvider":false,"definitionProvider":true,"hoverProvider":true,"codeActionProvider":true,"completionProvider":{"triggerCharacters":["."],"resolveProvider":true},"documentSymbolProvider":true,"documentFormattingProvider":true,"referencesProvider":true}},"jsonrpc":"2.0","id":0}
2020-01-12 17:07:07.12489 [ThreadId 9] - GHC Output: "Just "/nix/store/cw0qkjjk3y9qjxls1s6c7vd51jbaa575-ghc-8.6.5-with-packages/lib/ghc-8.6.5""
2020-01-12 17:07:07.128979 [ThreadId 16] - ideDispatcher: top of loop
2020-01-12 17:07:07.139902 [ThreadId 15] - ghcDispatcher: top of loop

and then nothing more.

This is an issue for upstream and not all-hies.
However, some answers: we have essentially dropped support for cabal v1-projects. Personally, I thought that v2 also works for v1 projects, but here we go, I learned something new.
Even with hie.yaml you are using v2, since it uses cabal v2-repl to load dependencies.
We probably can patch HIE to make it work again, for now, HIE 1.0.0.0 will not work for you, afaict.

@fendor thank you, I understand. I will likely have to switch to a setup with haskell.nix and cabal.project where I can use a nix-shell that prepares the dependencies of all project packages and not only the current one.

With #64 merged, there is now a set of templates showing how to get a working project environment: https://github.com/Infinisil/all-hies/tree/master/templates