-
-
Notifications
You must be signed in to change notification settings - Fork 391
Rework troubleshooting section, add basic explainer #2517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
65dd291
Rework troubleshooting section, add basic explainer
michaelpj 2bd9003
Merge branch 'master' into mpj/troubleshooting-work
Anton-Latukha f078a9a
Update docs/troubleshooting.md
michaelpj de4213c
Reorganize a bit
michaelpj dcaa60a
Merge branch 'master' into mpj/troubleshooting-work
mergify[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,163 @@ | ||
# Troubleshooting | ||
|
||
## Known limitations | ||
## Help, I have no idea what these words mean | ||
|
||
### Limited GHC 9 Support | ||
Currently, GHC 9 support in HLS is in beta stage; some features are unavailable with GHC >= 9.0.1 for the time being. | ||
This situation is expected to be resolved in the near future after all the dependent packages support GHC 9. | ||
See issue [#297](https://github.com/haskell/haskell-language-server/issues/297) for the supported features in GHC 9 and the status of migration progress. | ||
If you are new to the project, you may find it helpful to read the [introduction](./what-is-hls.md) page, which explains some of the terminology used on this page. | ||
|
||
### Preprocessor | ||
HLS is not yet able to find project preprocessors, which may result in `could not execute: <preprocessor>` errors. This problem is | ||
tracked in https://github.com/haskell/haskell-language-server/issues/176 and originally comes from https://github.com/mpickering/hie-bios/issues/125 | ||
## Getting help | ||
|
||
As a workaround, you need to ensure the preprocessor is available in the path (install globally with Stack or Cabal, provide in `shell.nix`, etc.). | ||
### Where to ask | ||
|
||
Example with `tasty-discover`: | ||
Many of the developers are active on [IRC](https://web.libera.chat/?channels=#haskell-language-server). | ||
However, the most direct way to get help is to open an [issue](https://github.com/haskell/haskell-language-server/issues). | ||
|
||
```haskell | ||
{-# OPTIONS_GHC -F -pgmF tasty-discover #-} | ||
``` | ||
If you can diagnose whether a problem is with HLS or with the client that you are using, then it is helpful to open an issue in the appropriate repository. | ||
But this can be tricky, and if you're not sure then you can always open one in the HLS repository and we'll help you figure out what's going on. | ||
|
||
This returns an error in HLS if 'tasty-discover' is not in the path: `could not execute: tasty-discover`. | ||
### What to include | ||
|
||
### Problems with multi component (tests suites, executables, benchmarks) support using stack | ||
Please try and give us as much information as you can! | ||
In particular, the more you can diagnose the problem, the better. | ||
|
||
Due to some limitations in the interaction between HLS and stack, there are some issues in projects with a main library and executables, test suites or benchmarks: | ||
- The stack project has to be built succesfully *before* loading it with HLS to get components other than the library work. | ||
- Changes in the library are not automatically propagated to other components, especially in the presence of errors in the library, so you have to restart HLS to get those components correctly loaded. The usual symptom is the editor showing errors like `Could not load module ...` or `Cannot satisfy -package ...` | ||
- See https://github.com/haskell/haskell-language-server/issues/366 for more info about. | ||
## Common issues | ||
## Basic diagnosis steps | ||
|
||
### Problems with dynamic linking | ||
### Quick diagnosis checklist | ||
|
||
As haskell-language-server prebuilt binaries are statically linked, they don't play well with projects using dynamic linking. | ||
An usual symptom is the presence of errors containing `unknown symbol` and it is typical in arch linux, where a dynamically linked version of ghc is used. | ||
1. Is the server binary running at all? (check process monitors etc.) If not, there may be a client or installation problem. | ||
2. Is the client connecting to the server? (check for indicators in the editor etc.) If not, there may be a client problem. | ||
michaelpj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
3. Is the project being built correctly by HLS? (check for "wrong" compilation errors etc.) If not, there may be a cradle problem. | ||
4. Is basic functionality working? (check hover documentation etc.) If not, there may be a server problem. | ||
5. Are there specific files that exhibit problems? If not, there may be a server problem. | ||
|
||
The workaround is to use a version of haskell-language-server compiled from source with the ghc option `-dynamic` enabled. See more details [here](https://github.com/haskell/haskell-language-server/issues/1160#issuecomment-756566273). | ||
### Finding your `haskell-language-server` binary | ||
|
||
### Support for Template Haskell | ||
Several of the diagnostic steps require you to run the actual `haskell-language-server` binary that is installed on your computer. | ||
|
||
Template Haskell should work fine in Linux and Windows with the distributed binaries. In Mac Os a dynamically linked binary of HLS is required to avoid segmentation faults. The easiest way to obtain a dynamically linked HLS binary is to build it locally. With cabal install this can be done as follows: | ||
Where the binary is will depend on how you installed HLS. | ||
Consult the [installation](./installation.md) page for help. | ||
|
||
cabal update && cabal install haskell-language-server --enable-executable-dynamic | ||
As usual, if you installed HLS with the wrapper, you will want to run `haskell-language-server-wrapper` instead. | ||
|
||
## Troubleshooting the server | ||
### Getting basic information | ||
|
||
### Diagnostic mode | ||
Running `haskell-language-server --probe-tools` will produce useful information, such as the version of HLS that you are using. | ||
Including this in issue reports is helpful. | ||
|
||
The `haskell-language-server` executable can be run in diagnostic mode, where it will just try to load modules from your project, printing all of its output to stdout. | ||
This makes it much easier to see what's going on and to diagnose build-related problems. | ||
### Working out where the problem is | ||
|
||
To do this, simply run the executable directly from your shell in the project root. | ||
You can either run it without an argument, in which case it will load random modules, or with a path, in which case it will load modules in that file or directory. | ||
The most important thing to figure out is whether you are looking at an issue with the _client_ or the _server_. | ||
This can be tricky to work out: if in doubt, open an issue and we'll help you figure it out. | ||
|
||
### Examining the log | ||
Typical examples of client issues: | ||
- The wrong server binary is being launched | ||
- Diagnostics are being shown in the wrong place | ||
|
||
Typical examples of server issues: | ||
- The server crashes on certain files | ||
- A code action doesn't work the way it's supposed to | ||
|
||
Unclear examples: | ||
- Hover documentation looks wrong (the client might be rendering it wrong, or the server might be sending the wrong thing) | ||
- Missing functionality (the client might not support it, or the server might not support it) | ||
|
||
## Diagnosing problems with the server | ||
|
||
### Examining the server log | ||
|
||
Most clients will launch `haskell-language-server` with `--logfile` to make it write a log file. | ||
Please consult the documentation for your client to find out where this is (or how to set it). | ||
|
||
The log will contain all the messages that are sent to the server and its responses. | ||
This is helpful for low-level debugging: if you expect a certain action to happen, you can look in the log to see if the corresponding messages are | ||
sent, or if there are any errors. | ||
This is helpful for low-level debugging: if you expect a certain action to happen, you can look in the log to see if the corresponding messages are sent, or if there are any errors. | ||
|
||
To get a more verbose log, you can also pass the `--debug` argument to the server. | ||
|
||
### Reproducing failures on the command-line | ||
|
||
To get a more verbose, also pass `--debug` to the executable. | ||
The `haskell-language-server` binary can be with a specific file as an argument, which will make it try and load that file specifically. | ||
If you are having trouble loading a file in the editor, then loading it in this way can help make the failure more obvious and reproducible. | ||
|
||
### Identify which plugin could be the cause of the issue. | ||
This also provides an easy way to get the logs (with or without `--debug`) if you are having trouble finding them when the server is launched by the client. | ||
|
||
Sometimes the issue is produced by one of the plugins included in HLS. To diagnose that and help to trace the final cause one possible strategy is simple disable all plugins, check if the issue is gone and then enable them selectively until the issue is reproduced again. | ||
### Plugin-related issues | ||
|
||
There is a configuration json snippet which disables all plugins [here](https://github.com/haskell/haskell-language-server/issues/2151#issuecomment-911397030). | ||
Sometimes the issue is related to one of HLS's plugins. | ||
One strategy for diagnosing this is simply disable all plugins, check if the issue is gone and then enable them selectively until the issue is reproduced again. | ||
|
||
## Troubleshooting the client | ||
There is a configuration JSON snippet which disables all plugins [here](https://github.com/haskell/haskell-language-server/issues/2151#issuecomment-911397030). | ||
|
||
## Diagnosing problems with the client | ||
|
||
The most important thing to do is to consult the client's documentation. | ||
Usually this will provide some information about troubleshooting. | ||
|
||
For example: | ||
- `lsp-mode` has a [troubleshooting page](https://emacs-lsp.github.io/lsp-mode/page/troubleshooting/) | ||
- The VSCode Haskell extension has a [troubleshooting section](https://github.com/haskell/vscode-haskell#investigating-and-reporting-problems) | ||
|
||
Many clients provide diagnostic information about a LSP session. | ||
In particular, look for a way to get the status of the server, the server stderr, or a log of the messages that the client has sent to the server. | ||
For example, `lsp-mode` provides all of these (see its [troubleshooting page](https://emacs-lsp.github.io/lsp-mode/page/troubleshooting/) for details). | ||
For vscode you can read how to access the lsp session log [here])https://github.com/haskell/vscode-haskell#investigating-and-reporting-problems). | ||
|
||
## Common issues | ||
|
||
### Wrong server binary being used | ||
|
||
HLS needs to be compiled against the same version of GHC as is used in the project. | ||
Normally, we ship binaries for multiple versions and `haskell-language-server-wrapper` selects the correct one. | ||
|
||
If you see an error about HLS being compiled with the wrong version of GHC, then you either need to install the correct one (if you installed it yourself), or there is something going wrong with the wrapper selecting the right HLS binary to launch. | ||
|
||
### Unsupported GHC version | ||
|
||
HLS does not support every GHC version - there are a lot of them! | ||
Please see the [supported versions page](./supported-versions.md) for more information. | ||
|
||
In particular, support for GHC 9.0 and 9.2 is only partial; some features are unavailable with GHC >= 9.0.1, and HLS is not available at all for GHC 9.2. | ||
|
||
### Missing server or build tools | ||
|
||
The most common client-related problem is the client simply not finding the server executable or the tools needed to load Haskell code (`ghc`, `cabal`, or `stack`). So make sure that you have the right `PATH` and you have configured the client to look for the right executables. | ||
|
||
Usually this will be visible in the client's log. | ||
|
||
### Compilation failures | ||
|
||
Sometimes HLS will simply fail to do anything with a file, or give nonsensical error messages. | ||
The most common cause of this is that HLS is using the wrong `hie-bios` cradle to decide how to build the project (e.g., trying to use `stack` instead of `cabal`). | ||
The server log will show which cradle is being chosen. | ||
|
||
Using an explicit `hie.yaml` to configure the cradle can resolve the problem, see the [configuration page](./configuration.md#configuring-your-project-build). | ||
|
||
### Template Haskell | ||
|
||
**tl;dr** Use a dynamically linked HLS binary. | ||
|
||
The easiest way to obtain a dynamically linked HLS binary is to build it locally. With `cabal` this can be done as follows: | ||
|
||
cabal update && cabal install haskell-language-server --enable-executable-dynamic | ||
|
||
With `stack` you need to manually add the ghc option `-dynamic`. | ||
|
||
Static binaries use the GHC linker for dynamically loading dependencies when typechecking TH code, and this can run into issues when loading shared objects linked against mismatching system libraries, or into GHC linker bugs (mainly the Mach linker used in Mac OS, but also potentially the ELF linker). Dynamically linked binaries (including`ghci`) use the system linker instead of the GHC linker and avoid both issues. | ||
|
||
Note: HLS binaries prior to 1.6.0 were statically linking `glibc` which is not a supported configuration and has been replaced by `musl`. | ||
|
||
### Preprocessors | ||
|
||
HLS is [not yet](https://github.com/haskell/haskell-language-server/issues/176) able to find project preprocessors, which may result in `could not execute: <preprocessor>` errors. | ||
|
||
As a workaround, you can ensure the preprocessor is available in `PATH` (install globally with Stack or Cabal, provide in `shell.nix`, etc.). | ||
|
||
Example with `tasty-discover`: | ||
|
||
```haskell | ||
{-# OPTIONS_GHC -F -pgmF tasty-discover #-} | ||
``` | ||
|
||
This returns an error in HLS if `tasty-discover`` is not in the path: `could not execute: tasty-discover`. | ||
|
||
### Problems with multi component support using stack | ||
|
||
Due to some limitations in the interaction between HLS and `stack`, there are [issues](https://github.com/haskell/haskell-language-server/issues/366) in projects with multiple components (i.e. a main library and executables, test suites or benchmarks): | ||
- The project has to be built succesfully *before* loading it with HLS to get components other than the library work. | ||
- Changes in the library are not automatically propagated to other components, especially in the presence of errors in the library. So you have to restart HLS in order for those components to be loaded correctly. The usual symptom is the editor showing errors like `Could not load module ...` or `Cannot satisfy -package ...`. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.