haskell / ghcup-hs

https://www.haskell.org/ghcup/
GNU Lesser General Public License v3.0
284 stars 88 forks source link

HLS installed via ghcup seems to try to open `/opt/ghc.../settings` #104

Closed hasufell closed 1 year ago

hasufell commented 3 years ago

In GitLab by @Jasagredo on Nov 24, 2020, 19:21

I created a small stack project with stack new example and then filled the Lib module with this function that has a redundant id:

module Lib where

bar x = id x

I'm editing this in Emacs with lsp-mode. Whenever I try to apply an hlint suggestion (which are correctly shown on the lsp UI), it fails with the following error. The error doesn't seem to be on the LSP part of the environment, but instead in some configuration inside HLS that points to /opt/ghc/8.8.4/lib/ghc-8.8.4/settings:

image

This is the relevant output of the lsp-haskell:stderr buffer:

Found "/home/javier/example/hie.yaml" for "/home/javier/example/a"
Module "/home/javier/example/a" is loaded by Cradle: Cradle {cradleRootDir = "/home/javier/example", cradleOptsProg = CradleAction: Stack}
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 0.6.0.0, Git revision 372a12e797069dc3ac4fa33dcaabe3b992999d7c (dirty) x86_64 ghc-8.10.1
Current directory: /home/javier/example
Operating system: linux
Arguments: ["--lsp","-d","-l","/tmp/hls.log"]
Cradle directory: /home/javier/example
Cradle type: Stack

Tool versions found on the $PATH
cabal:      3.2.0.0
stack:      2.5.1
ghc:        8.8.4

Consulting the cradle to get project GHC version...
Project GHC version: 8.8.4
haskell-language-server exe candidates: ["haskell-language-server-8.8.4","haskell-language-server-8.8","haskell-language-server"]
Launching haskell-language-server exe at:/home/javier/.ghcup/bin/haskell-language-server-8.8.4
haskell-language-server version: 0.6.0.0 (GHC: 8.8.4) (PATH: /home/javier/.ghcup/bin/haskell-language-server-8.8.4~0.6.0) (GIT hash: 372a12e797069dc3ac4fa33dcaabe3b992999d7c)
Starting (haskell-language-server)LSP server...
  with arguments: LspArguments {argLSP = True, argsCwd = Nothing, argFiles = [], argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = True, argsLogFile = Just "/tmp/hls.log", argsThreads = 0, argsProjectGhcVersion = False}
  with plugins: [PluginId "brittany",PluginId "eval",PluginId "floskell",PluginId "fourmolu",PluginId "ghcide",PluginId "hlint",PluginId "importLens",PluginId "moduleName",PluginId "ormolu",PluginId "pragmas",PluginId "retrie",PluginId "stylish-haskell",PluginId "tactic"]
  in directory: /home/javier/example
If you are seeing this in a terminal, you probably should have run ghcide WITHOUT the --lsp option!
 Started LSP server in 0.00s
Output from setting up the cradle Cradle {cradleRootDir = "/home/javier/example", cradleOptsProg = CradleAction: Stack}
> Using main module: 1. Package `example' component example:exe:example-exe with main-is file: /home/javier/example/app/Main.hs
> Building all executables for `example' once. After a successful build of all of them, only specified executables will be rebuilt.
> example> configure (lib + exe)
> Configuring example-0.1.0.0...
> example> initial-build-steps (lib + exe)
> The following GHC options are incompatible with GHCi and have not been passed to it: -threaded
> Configuring GHCi with the following packages: example
> 
> * * * * * * * *
> 
> Warning: Multiple files use the same module name:
>          * Paths_example found at the following paths
>            * /home/javier/example/.stack-work/dist/x86_64-linux/Cabal-3.0.1.0/build/autogen/Paths_example.hs (example:lib)
>            * /home/javier/example/.stack-work/dist/x86_64-linux/Cabal-3.0.1.0/build/example-exe/autogen/Paths_example.hs (example:exe:example-exe)
> * * * * * * * *
> 
> /home/javier/example/.stack-work/install/x86_64-linux/95147a863182f051bbb02c2d82ede4eafd6b7ef0da0f0f540b7178cf1fa76fec/8.8.4/pkgdb:/home/javier/.stack/snapshots/x86_64-linux/95147a863182f051bbb02c2d82ede4eafd6b7ef0da0f0f540b7178cf1fa76fec/8.8.4/pkgdb:/home/javier/.ghcup/ghc/8.8.4/lib/ghc-8.8.4/package.conf.d
/opt/ghc/8.8.4/lib/ghc-8.8.4/settings: openFile: does not exist (No such file or directory)
/opt/ghc/8.8.4/lib/ghc-8.8.4/settings: openFile: does not exist (No such file or directory)

It seems that as it is failing, lsp-mode thinks the action is not implemented:

<from the minibuffer echo area>
LSP :: Please open an issue in lsp-mode for implementing `77313:hlint:applyOne'.

(error "ExitFailure 1")

Note that HLS and GHC were installed via ghcup and system-ghc: true was added to ~/.stack/config.yaml: image

Also hlint was installed with stack:

❯ which hlint
/home/javier/.local/bin/hlint
❯ hlint --version
HLint v3.1.6, (C) Neil Mitchell 2006-2020
hasufell commented 3 years ago

In GitLab by @maerwald on Nov 24, 2020, 23:15

See https://github.com/haskell/haskell-language-server/issues/591