Skip to content

Commit 53a05f3

Browse files
Merge branch 'master' into 2021-12-21-ci-fxs
2 parents 2a379f3 + 82b91ac commit 53a05f3

File tree

6 files changed

+230
-72
lines changed

6 files changed

+230
-72
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@ assignees: ''
88
---
99

1010
<!--
11-
Before opening an issue, please take a look at the [troubleshooting guide](https://haskell-language-server.readthedocs.io/en/latest/troubleshooting.html). This explains some common issues and will also help you to find the information that the issue template asks for.
11+
Before opening an issue, please take a look at the [troubleshooting guide](https://haskell-language-server.readthedocs.io/en/latest/troubleshooting.html).
12+
This explains some common issues and will also help you to find the information that the issue template asks for.
1213
13-
When filing an issue, please fill out as much of the information below as you can. This helps us to debug your issue, but is not required!
14+
When filing an issue, please fill out as much of the information below as you can.
15+
This helps us to debug your issue, but is not required!
1416
-->
1517

1618
### Your environment
1719

1820
Which OS do you use:
1921
<!-- Windows, MacOS, Ubuntu, ArchLinux, etc... -->
20-
Which lsp-client do you use:
21-
<!-- Neovim, emacs, VS Codium, etc... -->
22+
Which LSP client (editor/plugin) do you use:
23+
<!-- Neovim+LanguageClient-neovim, emacs+lsp-mode, VS Codium+vscode-haskell, etc... -->
2224
Describe your project (alternative: link to the project):
2325
<!-- stack.yaml, package.yaml, *.cabal files, cabal.project, hie.yaml -->
2426

@@ -32,26 +34,5 @@ Describe your project (alternative: link to the project):
3234
<!-- Tell us what happens instead. -->
3335

3436
### Include debug information
35-
Execute in the root of your project the command `haskell-language-server-wrapper --debug .` and paste the logs here:
36-
(if you are using the vscode extension check the executable location [here](https://github.com/haskell/vscode-haskell#downloaded-binaries))
37-
<details>
38-
<summary>
39-
Debug output:
40-
</summary>
41-
42-
```
43-
<paste your logs here>
44-
```
45-
</details>
46-
47-
Paste the logs from the lsp-client, you can check instructions about for VS Code [here](https://github.com/haskell/vscode-haskell#troubleshooting)
48-
49-
<details>
50-
<summary>
51-
LSP logs:
52-
</summary>
53-
54-
```
55-
<paste your logs here>
56-
```
57-
</details>
37+
38+
<!-- Include any useful debug information, such as relevant log snippets. -->

docs/conf.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
# ones.
5858
extensions = [
5959
'myst_parser',
60-
'sphinx_rtd_theme'
60+
'sphinx_rtd_theme',
61+
'sphinx.ext.autosectionlabel'
6162
]
6263

6364
# Add any paths that contain templates here, relative to this directory.

docs/index.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
haskell-language-server
22
=======================
33

4-
Official haskell ide support via language server (LSP). Successor of `ghcide <https://github.com/haskell/ghcide>`_ and `haskell-ide-engine <https://github.com/haskell/haskell-ide-engine>`_. Read the `project's background <https://neilmitchell.blogspot.com/2020/01/one-haskell-ide-to-rule-them-all.html>`_.
4+
Official Haskell Language Server implementation. :ref:`Read more<What is haskell-language-server?>`.
55

66
.. toctree::
77
:maxdepth: 2
88

9+
what-is-hls
910
features
1011
installation
1112
supported-versions

docs/installation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ choco install haskell-language-server
3939

4040
If you are using Visual Studio Code, the [Haskell extension](https://marketplace.visualstudio.com/items?itemName=haskell.haskell) will automatically download and install `haskell-language-server` for you.
4141

42+
If you need to find the binaries, please consult the [documentation](https://github.com/haskell/vscode-haskell#downloaded-binaries) for the extension.
43+
4244
## Pre-built binaries
4345

4446
There are pre-built binaries available from the [releases page](https://github.com/haskell/haskell-language-server/releases) for Linux, Windows and macOS.

docs/troubleshooting.md

Lines changed: 154 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,190 @@
11
# Troubleshooting
22

3-
## Known limitations
3+
## Help, I have no idea what these words mean
44

5-
### Limited GHC 9 Support
6-
Currently, GHC 9 support in HLS is in beta stage; some features are unavailable with GHC >= 9.0.1 for the time being.
7-
This situation is expected to be resolved in the near future after all the dependent packages support GHC 9.
8-
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.
5+
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.
96

10-
### Preprocessor
11-
HLS is not yet able to find project preprocessors, which may result in `could not execute: <preprocessor>` errors. This problem is
12-
tracked in https://github.com/haskell/haskell-language-server/issues/176 and originally comes from https://github.com/mpickering/hie-bios/issues/125
7+
## Getting help
138

14-
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.).
9+
### Where to ask
1510

16-
Example with `tasty-discover`:
11+
Many of the developers are active on [IRC](https://web.libera.chat/?channels=#haskell-language-server).
12+
However, the most direct way to get help is to open an [issue](https://github.com/haskell/haskell-language-server/issues).
1713

18-
```haskell
19-
{-# OPTIONS_GHC -F -pgmF tasty-discover #-}
20-
```
14+
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.
15+
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.
2116

22-
This returns an error in HLS if 'tasty-discover' is not in the path: `could not execute: tasty-discover`.
17+
### What to include
2318

24-
### Problems with multi component (tests suites, executables, benchmarks) support using stack
19+
Please try and give us as much information as you can!
20+
In particular, the more you can diagnose the problem, the better.
2521

26-
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:
27-
- The stack project has to be built succesfully *before* loading it with HLS to get components other than the library work.
28-
- 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 ...`
29-
- See https://github.com/haskell/haskell-language-server/issues/366 for more info about.
30-
## Common issues
22+
## Basic diagnosis steps
3123

32-
### Problems with dynamic linking
24+
This section lists a few basic diagnostic steps that are almost always helpful.
3325

34-
As haskell-language-server prebuilt binaries are statically linked, they don't play well with projects using dynamic linking.
35-
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.
26+
Sometimes these checks may be enough to work out where the problem is.
27+
If not, refer to the sections below about diagnosing problems with the server and client, respectively.
28+
That will also require you to figure out is whether you are looking at an issue with the server or the client.
29+
This can be tricky to work out: if in doubt, open an issue and we'll help you figure it out.
3630

37-
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).
31+
Typical examples of client issues:
32+
- The wrong server binary is being launched
33+
- Diagnostics are being shown in the wrong place
3834

39-
### Support for Template Haskell
35+
Typical examples of server issues:
36+
- The server crashes on certain files
37+
- A code action doesn't work the way it's supposed to
4038

41-
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:
39+
Unclear examples:
40+
- Hover documentation looks wrong (the client might be rendering it wrong, or the server might be sending the wrong thing)
41+
- Missing functionality (the client might not support it, or the server might not support it)
4242

43-
cabal update && cabal install haskell-language-server --enable-executable-dynamic
43+
### Finding your `haskell-language-server` binary
44+
45+
Several of the diagnostic steps require you to run the actual `haskell-language-server` binary that is installed on your computer.
46+
47+
Where the binary is will depend on how you installed HLS.
48+
Consult the [installation](./installation.md) page for help.
49+
50+
As usual, if you installed HLS with the wrapper, you will want to run `haskell-language-server-wrapper` instead.
51+
52+
### Getting basic information about your installation
53+
54+
Running `haskell-language-server --probe-tools` will produce useful information, such as the version of HLS that you are using.
55+
Including this in issue reports is helpful.
56+
57+
### Checking that the server is running
58+
59+
If the server isn't running at all when you are editing a Haskell file in your project, then that suggests that the client is having difficulty launching it.
60+
Often this means that the client is configured to run the wrong binary, or the correct one is not available in your `PATH`.
61+
62+
The easiest way to check whether the server is running is to use an OS process monitor to see if there is a `haskell-language-server` process running.
63+
64+
### Checking whether the client is connecting to the server
4465

45-
## Troubleshooting the server
66+
If the server is running, you should see some kind of indicator in your client.
67+
In some clients (e.g. `coc`) you may need to run a command to query the client's beliefs about the server state.
68+
If the client doesn't seem to be connected despite the server running, this may indicate a bug in the client or HLS.
4669

47-
### Diagnostic mode
70+
### Checking whether the project is being built correctly by HLS
4871

49-
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.
50-
This makes it much easier to see what's going on and to diagnose build-related problems.
72+
HLS needs to build the project correctly, with the correct flags, and if it does not do so then very little is likely to work.
73+
A typical symptom of this going wrong is "incorrect" compilation errors being sent to the client.
5174

52-
To do this, simply run the executable directly from your shell in the project root.
53-
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.
75+
If this is happening, then it usually indicates a problem in the server's configuration.
5476

55-
### Examining the log
77+
### Checking whether basic functionality is working
78+
79+
If everything otherwise seems to be fine, then it is useful to check whether basic functionality is working.
80+
Hover documentation (at least including type signatures) is usually a good one to try.
81+
82+
### Identifying specific files that cause problems
83+
84+
If possible, identifying specific files that cause problems is helpful.
85+
If you want to be really helpful, minimising the example can really speed up diagnosis.
86+
87+
## Diagnosing problems with the server
88+
89+
### Examining the server log
5690

5791
Most clients will launch `haskell-language-server` with `--logfile` to make it write a log file.
5892
Please consult the documentation for your client to find out where this is (or how to set it).
5993

6094
The log will contain all the messages that are sent to the server and its responses.
61-
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
62-
sent, or if there are any errors.
95+
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.
96+
97+
To get a more verbose log, you can also pass the `--debug` argument to the server.
98+
99+
### Reproducing failures on the command-line
100+
101+
The `haskell-language-server` binary can be run from the command line.
63102

64-
To get a more verbose, also pass `--debug` to the executable.
103+
If it is run with a specific file as an argument, it will try and load that file specifically.
104+
If it is run without a specific file, it will try and load all the files in the project.
65105

66-
### Identify which plugin could be the cause of the issue.
106+
If you are having trouble loading one or many files in the editor, then testing it this way can help make the failure more obvious and reproducible.
67107

68-
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.
108+
Running HLS from the command-line directly also provides an easy way to get the logs (with or without `--debug`).
69109

70-
There is a configuration json snippet which disables all plugins [here](https://github.com/haskell/haskell-language-server/issues/2151#issuecomment-911397030).
110+
### Plugin-related issues
71111

72-
## Troubleshooting the client
112+
Sometimes the issue is related to one of HLS's plugins.
113+
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.
114+
115+
There is a configuration JSON snippet which disables all plugins [here](https://github.com/haskell/haskell-language-server/issues/2151#issuecomment-911397030).
116+
117+
## Diagnosing problems with the client
118+
119+
The most important thing to do is to consult the client's documentation.
120+
Usually this will provide some information about troubleshooting.
121+
122+
For example:
123+
- `lsp-mode` has a [troubleshooting page](https://emacs-lsp.github.io/lsp-mode/page/troubleshooting/)
124+
- The VSCode Haskell extension has a [troubleshooting section](https://github.com/haskell/vscode-haskell#investigating-and-reporting-problems)
73125

74126
Many clients provide diagnostic information about a LSP session.
75127
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.
76-
For example, `lsp-mode` provides all of these (see its [troubleshooting page](https://emacs-lsp.github.io/lsp-mode/page/troubleshooting/) for details).
77-
For vscode you can read how to access the lsp session log [here])https://github.com/haskell/vscode-haskell#investigating-and-reporting-problems).
128+
129+
## Common issues
130+
131+
### Wrong server binary being used
132+
133+
HLS needs to be compiled against the same version of GHC as is used in the project.
134+
Normally, we ship binaries for multiple versions and `haskell-language-server-wrapper` selects the correct one.
135+
136+
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.
137+
138+
### Unsupported GHC version
139+
140+
HLS does not support every GHC version - there are a lot of them!
141+
Please see the [supported versions page](./supported-versions.md) for more information.
142+
143+
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.
144+
145+
### Missing server or build tools
78146

79147
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.
148+
149+
Usually this will be visible in the client's log.
150+
151+
### Compilation failures
152+
153+
Sometimes HLS will simply fail to do anything with a file, or give nonsensical error messages.
154+
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`).
155+
The server log will show which cradle is being chosen.
156+
157+
Using an explicit `hie.yaml` to configure the cradle can resolve the problem, see the [configuration page](./configuration.md#configuring-your-project-build).
158+
159+
### Static binaries
160+
161+
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).
162+
Dynamically linked binaries (including`ghci`) use the system linker instead of the GHC linker and avoid both issues.
163+
164+
The easiest way to obtain a dynamically linked HLS binary is to build it locally. With `cabal` this can be done as follows:
165+
166+
cabal update && cabal install haskell-language-server --enable-executable-dynamic
167+
168+
With `stack` you need to manually add the ghc option `-dynamic`.
169+
170+
Note: HLS binaries prior to 1.6.0 were statically linking `glibc` which is not a supported configuration and has been replaced by `musl`.
171+
172+
### Preprocessors
173+
174+
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.
175+
176+
As a workaround, you can ensure the preprocessor is available in `PATH` (install globally with Stack or Cabal, provide in `shell.nix`, etc.).
177+
178+
Example with `tasty-discover`:
179+
180+
```haskell
181+
{-# OPTIONS_GHC -F -pgmF tasty-discover #-}
182+
```
183+
184+
This returns an error in HLS if `tasty-discover`` is not in the path: `could not execute: tasty-discover`.
185+
186+
### Problems with multi component support using stack
187+
188+
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):
189+
- The project has to be built succesfully *before* loading it with HLS to get components other than the library work.
190+
- 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 ...`.

0 commit comments

Comments
 (0)