Description
Your environment
Which OS do you use?
ArchLinux
Which version of GHC do you use and how did you install it?
9.8.2, managed via GHCup
How is your project built (alternative: link to the project)?
Just created a project via cabal init --simple
, answering 2) Executable
to the first and only question.
Which LSP client (editor/plugin) do you use?
Terminal Vim + YCM
Which version of HLS do you use and how did you install it?
Should be 2.9.0.1, if I understand correctly (see debug info).
Have you configured HLS in any way (especially: a hie.yaml
file)?
Not that I'm aware of (and log says definitely I don't have a hie.yaml
file), but please ask specific question if anything makes you think I have.
Steps to reproduce
- Initialize a project with
cabal init --simple
, - add the line
f = when
, - ask for
FixIt
onwhen
, - choose 4, i.e.
import Control.Monad (when)
(any other will do I guess)
Expected behaviour
import Control.Monad (when)
should be added in the preamble of the file.
Actual behaviour
Expected behavior does not happen, and this error is triggered instead:
ResponseFailedException: Request failed: -32601: No plugins are available to handle this SMethod_CodeActionResolve request.
Plugins installed for this method, but not available to handle this request are:
explicit-fields does not handle resolve requests for (unable to determine resolve owner)).
hlint does not handle resolve requests for (unable to determine resolve owner)).
overloaded-record-dot does not handle resolve requests for (unable to determine resolve owner)).
importLens does not handle resolve requests for (unable to determine resolve owner)).
Debug information
This is the log of the HLS:
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.1 x86_64 ghc-9.10.1
Current directory: /home/enrico/deleteme
Operating system: linux
Arguments: ["--lsp"]
Cradle directory: /home/enrico/deleteme
Cradle type: Cabal
Tool versions found on the $PATH
cabal: 3.12.1.0
stack: Not found
ghc: 9.8.2
Consulting the cradle to get project GHC version...
2024-12-17T16:50:16.704393Z | Debug | cabal exec -v0 -- ghc --print-libdir
2024-12-17T16:50:16.877467Z | Debug | cabal exec -v0 -- ghc -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)
2024-12-17T16:50:16.951529Z | Debug | cabal --builddir=/home/enrico/.cache/hie-bios/dist-deleteme-2ffc2a9ada40f7066b50bcbb85df6a6d v2-exec --with-compiler /home/enrico/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/enrico/.cache/hie-bios/ghc-pkg-4dd077f01ab89a1f905d2fbf68335958 ghc -v0 -- --numeric-version
Environment Variables
HIE_BIOS_GHC: /home/enrico/.ghcup/ghc/9.8.2/lib/ghc-9.8.2/bin/ghc-9.8.2
HIE_BIOS_GHC_ARGS: -B/home/enrico/.ghcup/ghc/9.8.2/lib/ghc-9.8.2/lib
Project GHC version: 9.8.2
haskell-language-server exe candidates: ["haskell-language-server-9.8.2","haskell-language-server"]
Launching haskell-language-server exe at:/home/enrico/.ghcup/bin/haskell-language-server-9.8.2
2024-12-17T16:50:17.014191Z | Debug | cabal exec -v0 -- ghc --print-libdir
2024-12-17T16:50:17.154485Z | Debug | cabal exec -v0 -- ghc -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)
2024-12-17T16:50:17.326941Z | Debug | cabal --builddir=/home/enrico/.cache/hie-bios/dist-deleteme-2ffc2a9ada40f7066b50bcbb85df6a6d v2-exec --with-compiler /home/enrico/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/enrico/.cache/hie-bios/ghc-pkg-4dd077f01ab89a1f905d2fbf68335958 ghc -v0 -- -v0 -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)
Environment Variables
HIE_BIOS_GHC: /home/enrico/.ghcup/ghc/9.8.2/lib/ghc-9.8.2/bin/ghc-9.8.2
HIE_BIOS_GHC_ARGS: -B/home/enrico/.ghcup/ghc/9.8.2/lib/ghc-9.8.2/lib
2024-12-17T16:50:17.393004Z | Debug | cabal exec -v0 -- ghc --print-libdir
2024-12-17T16:50:17.541355Z | Debug | cabal exec -v0 -- ghc -package-env=- -ignore-dot-ghci -e Control.Monad.join (Control.Monad.fmap System.IO.putStr System.Environment.getExecutablePath)
2024-12-17T16:50:17.615097Z | Debug | cabal --builddir=/home/enrico/.cache/hie-bios/dist-deleteme-2ffc2a9ada40f7066b50bcbb85df6a6d v2-exec --with-compiler /home/enrico/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/enrico/.cache/hie-bios/ghc-pkg-4dd077f01ab89a1f905d2fbf68335958 ghc -v0 -- --print-libdir
Environment Variables
HIE_BIOS_GHC: /home/enrico/.ghcup/ghc/9.8.2/lib/ghc-9.8.2/bin/ghc-9.8.2
HIE_BIOS_GHC_ARGS: -B/home/enrico/.ghcup/ghc/9.8.2/lib/ghc-9.8.2/lib
2024-12-17T16:50:19.074650Z | Info | haskell-language-server version: 2.9.0.1 (GHC: 9.8.2) (PATH: /home/enrico/.ghcup/hls/2.9.0.1/lib/haskell-language-server-2.9.0.1/bin/haskell-language-server-9.8.2)
2024-12-17T16:50:19.075576Z | Info | Directory: /home/enrico/deleteme
2024-12-17T16:50:19.075750Z | Info | Starting (haskell-language-server) LSP server...
GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsLogLevel = Info, argsLogFile = Nothing, argsLogStderr = True, argsLogClient = False, argsThreads = 0, argsProjectGhcVersion = False}
PluginIds: [ pragmas-suggest
, pragmas-completion
, ghcide-code-actions-bindings
, ghcide-extend-import-action
, retrie
, stylish-haskell
, explicit-fields
, ghcide-code-actions-type-signatures
, ghcide-code-actions-fill-holes
, stan
, hlint
, changeTypeSignature
, ghcide-code-actions-imports-exports
, cabal-fmt
, notes
, ghcide-completions
, eval
, ghcide-type-lenses
, cabal
, overloaded-record-dot
, gadt
, LSPRecorderCallback
, importLens
, floskell
, codeRange
, class
, ormolu
, qualifyImportedNames
, ghcide-hover-and-symbols
, alternateNumberFormat
, rename
, splice
, moduleName
, semanticTokens
, fourmolu
, cabal-gild
, callHierarchy
, ghcide-core
, explicit-fixity
, pragmas-disable ]
2024-12-17T16:50:19.078922Z | Info | Logging heap statistics every 60.00s
2024-12-17T16:50:19.114935Z | Info | Starting LSP server...
If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option!
PluginIds: [ pragmas-suggest
, pragmas-completion
, ghcide-code-actions-bindings
, ghcide-extend-import-action
, retrie
, stylish-haskell
, explicit-fields
, ghcide-code-actions-type-signatures
, ghcide-code-actions-fill-holes
, stan
, hlint
, changeTypeSignature
, ghcide-code-actions-imports-exports
, cabal-fmt
, notes
, ghcide-completions
, eval
, ghcide-type-lenses
, cabal
, overloaded-record-dot
, gadt
, LSPRecorderCallback
, importLens
, floskell
, codeRange
, class
, ormolu
, qualifyImportedNames
, ghcide-hover-and-symbols
, alternateNumberFormat
, rename
, splice
, moduleName
, semanticTokens
, fourmolu
, cabal-gild
, callHierarchy
, ghcide-core
, explicit-fixity
, pragmas-disable ]
2024-12-17T16:50:19.115439Z | Info | Starting server
2024-12-17T16:50:19.117428Z | Info | Registering IDE configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri 3429100310501239661 "file:///home/enrico/deleteme"], clientSettings = hashed (Just (Object (fromList [])))}
2024-12-17T16:50:19.124235Z | Info | Started LSP server in 0.01s
2024-12-17T16:50:19.465468Z | Warning | LSP: can't register dynamically for: "workspace/didChangeConfiguration"
2024-12-17T16:50:19.471055Z | Info | Cradle path: app/Main.hs
2024-12-17T16:50:19.471207Z | Warning | No [cradle](https://github.com/mpickering/hie-bios#hie-bios) found for app/Main.hs.
Proceeding with [implicit cradle](https://hackage.haskell.org/package/implicit-hie).
You should ignore this message, unless you see a 'Multi Cradle: No prefixes matched' error.
2024-12-17T16:50:19.473468Z | Info | invoking build tool to determine build flags (this may take some time depending on the cache)
2024-12-17T16:50:19.843868Z | Info | Load cabal cradle using single file
2024-12-17T16:50:20.160300Z | Info | cabal --builddir=/home/enrico/.cache/hie-bios/dist-deleteme-2ffc2a9ada40f7066b50bcbb85df6a6d v2-repl --with-compiler /home/enrico/.cache/hie-bios/wrapper-b54f81dea4c0e6d1626911c526bc4e36 --with-hc-pkg /home/enrico/.cache/hie-bios/ghc-pkg-4dd077f01ab89a1f905d2fbf68335958 /home/enrico/deleteme/app/Main.hs
Environment Variables
HIE_BIOS_OUTPUT: /tmp/HIE_BIOS_OUTPUT457387-0
HIE_BIOS_GHC: /home/enrico/.ghcup/ghc/9.8.2/lib/ghc-9.8.2/bin/ghc-9.8.2
HIE_BIOS_GHC_ARGS: -B/home/enrico/.ghcup/ghc/9.8.2/lib/ghc-9.8.2/lib
2024-12-17T16:50:22.061086Z | Info | Interface files cache directory: /home/enrico/.cache/ghcide/deleteme-0.1.0.0-inplace-deleteme-c38452dbce672bbfc236ac73975e156b42d15720
2024-12-17T16:50:22.070915Z | Info | Making new HscEnv. In-place unit ids: [deleteme-0.1.0.0-inplace-deleteme]
2024-12-17T16:50:27.362922Z | Warning | No plugin handles this "codeAction/resolve" request.
Activity
fendor commentedon Dec 17, 2024
Hi, thank you for the bug report!
Unfortunately, I can not reproduce the described issue on GHC 9.6.6 or 9.8.2.
Perhaps something else is broken in addition?
Try running HLS with
--debug
and please share the logs of HLS, showing that the CodeAction failed.The
--log-file
option might be handy for obtaining the logs.Aster89 commentedon Dec 18, 2024
Content of the
log
file after executingis
fendor commentedon Dec 18, 2024
Can you try to execute the CodeAction in your editor while passing these flags to HLS?
Aster89 commentedon Dec 18, 2024
@fendor , would you mind clarifying which flags?
fendor commentedon Dec 18, 2024
The flags
--debug
and--log-file
:) If you run it in CLI mode, we can't see whether the code action execution failed in any way. So, ideally we get the logs of a real IDE run, with the additional logging output, where you try to use the code action, but HLS throws an error unexpectedly.Aster89 commentedon Dec 19, 2024
I've passed those options to HLS via the IDE (Vim+YCM); here's the log:
fendor commentedon Dec 20, 2024
Thanks! I am wondering whether this is related to #4451...
I still can't reproduce, so I guess this bug might be specific to vim and
YCM
.Aster89 commentedon Dec 26, 2024
@fendor , would you mind helping understand what I should expect from HLS, in this case? I mean, how can I use it in a standalone way so that I can see what messages it sends to the IDE?
I mean,
2024-12-17T16:50:27.362922Z | Warning | No plugin handles this "codeAction/resolve" request.
sounds a lot like YCM sends some request to HLS, and HLS doesn't find a plugin for it.fendor commentedon Dec 28, 2024
It looks like HLS supports
codeAction/resolve
, so vim always sends acodeAction/resolve
request to HLS. However, not all plugins and not allCodeAction
s have an associatedcodeAction/resolve
handler. For example, if theCodeAction
is cheap, there is no reason to do the roundtrip to the server.However, it looks like some clients added support for
*/resolve
requests and unconditionally asks forcodeAction/resolve
. HLS rejects this request in some instances, perhaps this leads to vim not applying the codefix it already has around locally.Presumably, you can tell your client to log the lsp messages. However, I am not sure how to do that with vim.
resolve
requests #4473*/resolve
requests #4478fendor commentedon Jan 6, 2025
@Aster89 In #4478, I implemented a fallback handler for
resolve
requests. To my understanding, this should fix your issue, could you give it a try?If you are using
ghcup
, then the following should work:ghcup compile hls -g enhance/plugins/handle-resolves --ghc <ghc-ver>
and then make sure vim is using that binary.17 remaining items