Skip to content

Commit e7d3d12

Browse files
ndmitchellcocreature
authored andcommitted
#129, add a very basic setup guide (#142)
1 parent a126bf3 commit e7d3d12

File tree

2 files changed

+43
-7
lines changed

2 files changed

+43
-7
lines changed

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Note: `ghcide` was previously called `hie-core`.
44

55
Our vision is that you should build an IDE by combining:
66

7-
87
<img style="float:right;" src="img/vscode2.png"/>
98

109
* [`hie-bios`](https://github.com/mpickering/hie-bios) for determining where your files are, what are their dependencies, what extensions are enabled and so on;
@@ -22,7 +21,7 @@ There are more details about our approach [in this blog post](https://4ta.uk/p/s
2221
| Feature | LSP name |
2322
| - | - |
2423
| Display error messages (parse errors, typecheck errors, etc.) and enabled warnings. | diagnostics |
25-
| Go to definition in local package | definition |
24+
| Go to definition in local package | definition |
2625
| Display type and source module of values | hover |
2726
| Remove redundant imports, replace suggested typos for values and module imports, fill type holes, insert missing type signatures, add suggested ghc extensions | codeAction (quickfix) |
2827
| Organize imports | codeAction (source.organizeImports) |
@@ -49,23 +48,22 @@ It's important that `ghcide` is compiled with the same compiler you use to build
4948

5049
Next, check that `ghcide` is capable of loading your code. Change to the project directory and run `ghcide`, which will try and load everything using the same code as the IDE, but in a way that's much easier to understand. For example, taking the example of [`shake`](https://github.com/ndmitchell/shake), running `ghcide` gives some error messages and warnings before reporting at the end:
5150

52-
```
53-
Files that worked: 152
54-
Files that failed: 6
51+
```console
52+
Files that failed:
5553
* .\model\Main.hs
5654
* .\model\Model.hs
5755
* .\model\Test.hs
5856
* .\model\Util.hs
5957
* .\output\docs\Main.hs
6058
* .\output\docs\Part_Architecture_md.hs
61-
Done
59+
Completed (152 worked, 6 failed)
6260
```
6361

6462
Of the 158 files in Shake, as of this moment, 152 can be loaded by the IDE, but 6 can't (error messages for the reasons they can't be loaded are given earlier). The failing files are all prototype work or test output, meaning I can confidently use Shake.
6563

6664
The `ghcide` executable mostly relies on [`hie-bios`](https://github.com/mpickering/hie-bios) to do the difficult work of setting up your GHC environment. If it doesn't work, see [the `hie-bios` manual](https://github.com/mpickering/hie-bios#readme) to get it working. My default fallback is to figure it out by hand and create a `direct` style [`hie.yaml`](https://github.com/ndmitchell/shake/blob/master/hie.yaml) listing the command line arguments to load the project.
6765

68-
Once you have got `ghcide` working outside the editor, the next step is to pick which editor to integrate with.
66+
If you can't get `ghcide` working outside the editor, see [this setup troubleshooting guide](docs/Setup.md). Once you have got `ghcide` working outside the editor, the next step is to pick which editor to integrate with.
6967

7068
### Using with VS Code
7169

docs/Setup.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Setup Troubleshooting
2+
3+
This page serves as a dumping ground for setup problems and their resolutions. We recommend everyone first runs `ghcide` on the console to check what files in their project load, and only the moves on to using `ghcide` through an editor (e.g. VS Code).
4+
5+
## "mismatched interface file versions"
6+
7+
If you see a problem such as:
8+
9+
```console
10+
File: ./test/Spec.hs
11+
Range: 1:0-1:0
12+
Source: typecheck
13+
Severity: DsError
14+
Message:
15+
test/Spec.hs:1:1: error:
16+
Bad interface file:
17+
/Users/daml/.stack/programs/x86_64-osx/ghc-8.6.4/lib/ghc-8.6.4/base-4.12.0.0/Prelude.hi
18+
mismatched interface file versions (wanted "8065", got "8064")
19+
```
20+
21+
The cause is that your program is configured to use a different GHC to the one you built `ghcide` with. In `ghcide` you can view the version number it was compiled with on the first line as:
22+
23+
```console
24+
ghcide version: 0.0.3 (GHC: 8.6.5)
25+
```
26+
27+
You can see the version of GHC being used by this project in the second-last line of the output with `ghc-8.6.4/`, or in in mismatch interfaces of wanted `8065` (aka 8.6.5), got `8064` (aka 8.6.4). The solution is to use the same GHC version in both places.
28+
29+
## Works in `ghcide` but not my editor
30+
31+
Does `ghcide` alone work on the console? Did you first enter a Nix shell? Or run `stack exec ghcide`? If so, there are two options:
32+
33+
1. Run your editor via the same mechanism, e.g. `stack exec code`.
34+
2. Change the extension to use the executable as `stack` and the arguments as `exec -- ghcide --lsp`.
35+
36+
## Issues with Nix
37+
38+
If you are using packages installed by Nix, then often Nix will set `NIX_GHC_LIBDIR` to say where the libraries are installed. `ghcide` can cope with that. However, sometimes the `ghc` on your shell will actually be a shell script that sets `NIX_GHC_LIBDIR`, which `ghcide` can't find. If that happens, you need to either set `NIX_GHC_LIBDIR` (so `ghcide` can see it) or use a proper [Nix compatible wrapper](https://github.com/hercules-ci/ghcide-nix) over `ghcide`.

0 commit comments

Comments
 (0)