tweag / cooked-validators

MIT License
39 stars 11 forks source link

HLS works in cooked-validators, fails in examples #75

Closed haroldcarr closed 2 years ago

haroldcarr commented 2 years ago

Note: I named the directory plutus-libs-tweag (instead of plutus-libs).

cd plutus-libs-tweag
nix-shell
emacs

In emacs, navigate to any haskell file in cooked-validators/src/*. HLS works correctly. Note: HLS works in cooked-validators/tests/* too. For success, the emacs buffer *lsp-haskell:stderr* contains:

Found "/Users/hcarr/plutus-libs-tweag/hie.yaml" for "/Users/hcarr/plutus-libs-tweag/a"
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.5.1.0 x86_64 ghc-8.10.4.20210212
Current directory: /Users/hcarr/plutus-libs-tweag
Operating system: darwin
Arguments: ["--lsp","-d","-l","/tmp/hls.log"]
Cradle directory: /Users/hcarr/plutus-libs-tweag
Cradle type: Cabal

Tool versions found on the $PATH
cabal:      3.6.2.0
stack:      2.7.3
ghc:        8.10.4.20210212

Consulting the cradle to get project GHC version...
Project GHC version: 8.10.4.20210212
haskell-language-server exe candidates: ["haskell-language-server-8.10.4.20210212","haskell-language-server"]
Launching haskell-language-server exe at:/nix/store/bqy1n8k5jb2hpf3zllg99qr7v49r9gbl-haskell-language-server-exe-haskell-language-server-1.5.1.0/bin/haskell-language-server
haskell-language-server version: 1.5.1.0 (GHC: 8.10.4.20210212) (PATH: /nix/store/bqy1n8k5jb2hpf3zllg99qr7v49r9gbl-haskell-language-server-exe-haskell-language-server-1.5.1.0/bin/haskell-language-server)
Starting (haskell-language-server)LSP server...
  with arguments: GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Just "/tmp/hls.log", argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "pragmas",PluginId "floskell",PluginId "fourmolu",PluginId "tactics",PluginId "ormolu",PluginId "stylish-haskell",PluginId "retrie",PluginId "brittany",PluginId "callHierarchy",PluginId "class",PluginId "haddockComments",PluginId "eval",PluginId "importLens",PluginId "refineImports",PluginId "moduleName",PluginId "hlint",PluginId "splice",PluginId "ghcide-hover-and-symbols",PluginId "ghcide-code-actions-imports-exports",PluginId "ghcide-code-actions-type-signatures",PluginId "ghcide-code-actions-bindings",PluginId "ghcide-code-actions-fill-holes",PluginId "ghcide-completions",PluginId "ghcide-type-lenses",PluginId "ghcide-core"]
  in directory: /Users/hcarr/plutus-libs-tweag

In emacs, navigate to any haskell file in examples/src/*. HLS fails.

The emacs *Messages* buffers contains:

LSP :: Connected to [lsp-haskell:93830].
LSP :: lsp-haskell has exited (exited abnormally with code 1)
LSP :: Sending to process failed with the following error: Process lsp-haskell not running
next-line: End of buffer
Server lsp-haskell:93830 exited with status exit(check corresponding stderr buffer for details). Do you want to restart it? (y or n) n

The emacs *lsp-haskell:stderr* buffer contains:

Found "/Users/hcarr/plutus-libs-tweag/hie.yaml" for "/Users/hcarr/plutus-libs-tweag/a"
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.5.1.0 x86_64 ghc-8.10.4.20210212
Current directory: /Users/hcarr/plutus-libs-tweag
Operating system: darwin
Arguments: ["--lsp","-d","-l","/tmp/hls.log"]
Cradle directory: /Users/hcarr/plutus-libs-tweag
Cradle type: Cabal

Tool versions found on the $PATH
cabal:      3.6.2.0
stack:      2.7.3
ghc:        8.10.4.20210212

Consulting the cradle to get project GHC version...
Project GHC version: 8.10.4.20210212
haskell-language-server exe candidates: ["haskell-language-server-8.10.4.20210212","haskell-language-server"]
Launching haskell-language-server exe at:/nix/store/bqy1n8k5jb2hpf3zllg99qr7v49r9gbl-haskell-language-server-exe-haskell-language-server-1.5.1.0/bin/haskell-language-server
haskell-language-server version: 1.5.1.0 (GHC: 8.10.4.20210212) (PATH: /nix/store/bqy1n8k5jb2hpf3zllg99qr7v49r9gbl-haskell-language-server-exe-haskell-language-server-1.5.1.0/bin/haskell-language-server)
Starting (haskell-language-server)LSP server...
  with arguments: GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Just "/tmp/hls.log", argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "pragmas",PluginId "floskell",PluginId "fourmolu",PluginId "tactics",PluginId "ormolu",PluginId "stylish-haskell",PluginId "retrie",PluginId "brittany",PluginId "callHierarchy",PluginId "class",PluginId "haddockComments",PluginId "eval",PluginId "importLens",PluginId "refineImports",PluginId "moduleName",PluginId "hlint",PluginId "splice",PluginId "ghcide-hover-and-symbols",PluginId "ghcide-code-actions-imports-exports",PluginId "ghcide-code-actions-type-signatures",PluginId "ghcide-code-actions-bindings",PluginId "ghcide-code-actions-fill-holes",PluginId "ghcide-completions",PluginId "ghcide-type-lenses",PluginId "ghcide-core"]
  in directory: /Users/hcarr/plutus-libs-tweag
 haskell-language-server-wrapper: callProcess: /nix/store/bqy1n8k5jb2hpf3zllg99qr7v49r9gbl-haskell-language-server-exe-haskell-language-server-1.5.1.0/bin/haskell-language-server "--lsp" "-d" "-l" "/tmp/hls.log" (exit -11): failed

Process lsp-haskell stderr finished

Environment

VictorCMiraldo commented 2 years ago

Could be the hie.yaml file that is too simplistic and hls is only working for the first project declared in the cabal.project. We probably need to bring in something like implicit-hie or rewrite hie.yaml to be:

cradle:
  cabal:
    - path: "cooked-validators/src"
      component: "lib:cooked-validators"

    - path: "examples/src"
      component: "lib:examples"
haroldcarr commented 2 years ago

I tried it using an hie.yaml file generated by gen-hie but it fails the same way. With no changes, does HLS work for you in examples?

Here is what gen-hie generates:

cradle:
  cabal:
    - path: "cooked-validators/src"
      component: "lib:cooked-validators"

    - path: "cooked-validators/tests/"
      component: "cooked-validators:test:spec"

    - path: "examples/src"
      component: "lib:examples"

    - path: "examples/tests"
      component: "examples:test:spec"
GuillaumeGen commented 2 years ago

For me, HLS works in src/PMultiSigStateful/DatumHijacking.hs, src/Forge.hs, src/PMultiSigStateful.hs, src/Split.hs and tests/UseCaseCrowdfundingSpec.hs exclusively (so roughly one third of the files of the examples folder). I heard recently that it is a known issue that the Plutus GHC plugin interacts badly with HLS. I assumed that it is the reason why some files of this folder does not support HLS, but I did not investigate it at all.

VictorCMiraldo commented 2 years ago

We've made multiple updates to the HLS and I've seen it working on the examples, closing this until we can repro it again!