I'm basically trying to build haskell-language-server from the source using stack, as per the instructions in the Contributing section (I want to actually play around with the source code)
Basically this:
$ cp hie.yaml.stack hie.yaml
$ cp install/hie.yaml.stack install/hie.yaml
$ stack build --test --no-run-tests
$ cd install
$ stack build
However, upon opening various projects, I get this error:
ghcide compiled against GHC 8.6.5 but currently using 8.8.4
This is unsupported, ghcide must be compiled with the same GHC version as the project.
This happened with multiple projects (and standalone files). Here is an example of a project configuration:
stack.yaml
resolver: lts-16.13
packages:
- xmobar-git
- xmonad-git
- xmonad-contrib-git
- .
extra-deps:
- netlink-1.1.1.0@sha256:d83424b5ba9921191449e4b1f53c7cba7f4375f2c55a9b737c77e982e1f40d00,3689
hie.yaml
cradle:
stack:
- path: "./src"
component: "xmonad-private:lib"
I don't think I'm supposed to recompile everything for each project. I use stack quite often so different projects have different ghc versions. If that is the case, how do I go about it? The goal here is to be able to make changes to the source of haskell-language-server and test them on different projects.
I feel that I'm missing something quite obvious, sorry if I am, and thanks for any help!
Hi, i am afraid that hls/ghcide needs to be compiled against the same ghc that is used by the project. Fortunately there exists a wrapper (haskell-language-server-wrapper) that analyzes your project and executes the appropiate haskell-language-server-${version} executable.
I would suggest to use the install script, that already generates the appropiate executables with stack install.hs hls-${version}, and use always the haskell-language-server-wrapper to launch the ide (see https://github.com/haskell/haskell-language-server#building for more info)
After reviewing the README i think the above explanation is not included clearly in it so it would need to be added.
EDIT: It is mentioned here: https://github.com/haskell/haskell-language-server#editor-integration but maybe it needs to be rewrited/moved
The contributing section doesn't mention that hint in the build instructions, which is what I followed. So using the install script or stack will both include the local changes to the source, correct?
@TheMC47 they both makes the source be adapted to the specific ghc version, in fact the install.hs script builds hls with stack underneath. However the install.hs script also copies the haskell-language-server executable with the appropiate extensions to the $PATH.
For example stack install hls-8.10.2 will copy haskell-language-server-8.10.2 and haskell-language-server-8.10 (in addition to the default haskell-language-server and haskell-language-server-wrapper).
Then, if you executes haskell-language-server-wrapper it will analyze your project, extract the ghc version used by and it will execute in turn the suited haskell-language-server-${ghcVersion}.
So, if you want test hls with, to say, ghc-8.10.2 and ghc-8.8.4, you have to install hls two times with stack install.hs hls-8.8.4 && stack install.hs hls-8.10.2
Awesome, thanks @jneira for the explanation. Then I guess the README needs to be updated!