emacs-lsp / lsp-haskell

lsp-mode :heart: haskell
https://emacs-lsp.github.io/lsp-haskell
GNU General Public License v3.0
227 stars 56 forks source link

haskell-language-server-wrapper from emacs behaviors is different from command line #154

Closed arademaker closed 1 year ago

arademaker commented 1 year ago

If I call the haskell-language-server-wrapper from the command line in the main folder of my project (created with stack), I get the outputs below. Not sure what the for "/Users/ar/Temp/lixo/a" means, but it seems to work as expected.

But, in the *lsp-haskell::stderr* buffer, I have a different result. Emacs found another version of GHC.. The current directory was wrongly associated with the parent folder of the project folder... How can I fix it? What am I missing?

No 'hie.yaml' found. Try to discover the project type!
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.7.0.0 x86_64 ghc-9.2.2
Current directory: /Users/ar/Temp
Operating system: darwin
Arguments: ["--lsp","-d","-l","/var/folders/b_/7nbv248s2nq019mcx58xrrb80000gn/T/hls.log"]
Cradle directory: /Users/ar/Temp
Cradle type: Default

Tool versions found on the $PATH
cabal:      3.6.2.0
stack:      2.7.5
ghc:        8.10.7

Consulting the cradle to get project GHC version...
Project GHC version: 8.10.7
haskell-language-server exe candidates: ["haskell-language-server-8.10.7","haskell-language-server"]
Launching haskell-language-server exe at:/Users/ar/.ghcup/bin/haskell-language-server-8.10.7

Command line:

ar@tenis lixo % haskell-language-server-wrapper
Found "/Users/ar/Temp/lixo/hie.yaml" for "/Users/ar/Temp/lixo/a"
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.7.0.0 x86_64 ghc-9.2.2
Current directory: /Users/ar/Temp/lixo
Operating system: darwin
Arguments: []
Cradle directory: /Users/ar/Temp/lixo
Cradle type: Stack

Tool versions found on the $PATH
cabal:      3.6.2.0
stack:      2.7.5
ghc:        8.10.7

Consulting the cradle to get project GHC version...
Project GHC version: 9.0.2
haskell-language-server exe candidates: ["haskell-language-server-9.0.2","haskell-language-server"]
Launching haskell-language-server exe at:/Users/ar/.ghcup/bin/haskell-language-server-9.0.2
2022-08-19T14:41:34.696256Z | Info | No log file specified; using stderr.
2022-08-19T14:41:34.700545Z | Info | haskell-language-server version: 1.7.0.0 (GHC: 9.0.2) (PATH: /Users/ar/.ghcup/hls/1.7.0.0/lib/haskell-language-server-1.7.0.0/bin/haskell-language-server-9.0.2)
2022-08-19T14:41:34.703039Z | Info | Directory: /Users/ar/Temp/lixo
2022-08-19T14:41:34.703374Z | Info | Logging heap statistics every 60.00s
 ghcide setup tester in /Users/ar/Temp/lixo.
Report bugs at https://github.com/haskell/haskell-language-server/issues

Step 1/4: Finding files to test in /Users/ar/Temp/lixo
Found 4 files

Step 2/4: Looking for hie.yaml files that control setup
Found 1 cradle
  (/Users/ar/Temp/lixo/hie.yaml)

Step 3/4: Initializing the IDE

Step 4/4: Type checking the files
2022-08-19T14:41:34.719184Z | Info | Cradle path: Setup.hs
2022-08-19T14:41:34.720457Z | Info | Cradle path: src/Lib.hs
2022-08-19T14:41:34.739216Z | Info | updateFileDiagnostics published different from new diagnostics - file diagnostics: File:     /Users/ar/Temp/lixo/Setup.hs
Hidden:   no
Range:    1:1-2:1
Source:   cradle
Severity: DsError
Message:
  Multi Cradle: No prefixes matched
  pwd: /Users/ar/Temp/lixo
  filepath: /Users/ar/Temp/lixo/Setup.hs
  prefixes:
  ("./src",Stack {component = Just "lixo:lib", stackYaml = Nothing})
  ("./app/Main.hs",Stack {component = Just "lixo:exe:lixo-exe", stackYaml = Nothing})
  ("./app/Paths_lixo.hs",Stack {component = Just "lixo:exe:lixo-exe", stackYaml = Nothing})
  ("./test",Stack {component = Just "lixo:test:lixo-test", stackYaml = Nothing})
....
arademaker commented 1 year ago

It is related to https://github.com/haskell/haskell-language-server/issues/3114

arademaker commented 1 year ago

More details

VS Code started just fine. Inspecting the processes I found

% ps aux | grep has
ar               50967   0.0  0.0 33588072    192 s002  R+    3:27PM   0:00.00 grep has
ar               50445   0.0  3.4 1108409952 571204   ??  Ss    3:26PM   0:01.45 /Users/ar/.ghcup/hls/1.7.0.0/lib/haskell-language-server-1.7.0.0/bin//haskell-language-server-8.10.7 --lsp -d -l /var/folders/b_/7nbv248s2nq019mcx58xrrb80000gn/T/hls.log
ar               48413   0.0  0.3 1107893416  44664   ??  S     3:21PM   0:01.62 /Users/ar/.ghcup/hls/1.7.0.0/lib/haskell-language-server-1.7.0.0/bin//haskell-language-server-9.0.2 --lsp

So VS Code found the right version of HLS

/Users/ar/.ghcup/hls/1.7.0.0/lib/haskell-language-server-1.7.0.0/bin//haskell-language-server-9.0.2 --lsp

But Emacs somehow is ignoring the information from my project (that uses GHC 9.0.2) and it is calling HLS 8.10.7:

/Users/ar/.ghcup/hls/1.7.0.0/lib/haskell-language-server-1.7.0.0/bin//haskell-language-server-8.10.7 --lsp -d -l /var/folders/b_/7nbv248s2nq019mcx58xrrb80000gn/T/hls.log
arademaker commented 1 year ago

I believe we can close now given my last comment in https://github.com/haskell/haskell-language-server/issues/3114#issuecomment-1221349783.