Closed dan-blank closed 2 years ago
what's wrong with starting VSCode from your ob shell?
It seems to not solve my problem: The VSC terminal seems to have the ob shell context, but HLS seems to not have this context, failing cabal exec -v0 -- ghc --print-libdir
, which works in the VSC terminal.
For the context:
I am developing in WSL2 (Ubuntu 20), these are my extension settings:
{
"workbench.colorTheme": "Default Light+",
"haskell.plugin.alternateNumberFormat.globalOn": false,
"haskell.plugin.callHierarchy.globalOn": false,
"haskell.plugin.changeTypeSignature.globalOn": false,
"haskell.plugin.class.globalOn": false,
"haskell.plugin.eval.config.diff": false,
"haskell.plugin.eval.globalOn": false,
"haskell.plugin.ghcide-code-actions-bindings.globalOn": false,
"haskell.plugin.ghcide-code-actions-fill-holes.globalOn": false,
"haskell.plugin.ghcide-code-actions-imports-exports.globalOn": false,
"haskell.plugin.ghcide-code-actions-type-signatures.globalOn": false,
"haskell.plugin.ghcide-completions.config.snippetsOn": false,
"haskell.plugin.ghcide-completions.globalOn": false,
"haskell.plugin.ghcide-hover-and-symbols.hoverOn": false,
"haskell.plugin.ghcide-hover-and-symbols.symbolsOn": false,
"haskell.plugin.ghcide-type-lenses.config.mode": "exported",
"haskell.plugin.ghcide-type-lenses.globalOn": false,
"haskell.plugin.haddockComments.globalOn": false,
"haskell.plugin.hlint.codeActionsOn": false,
"haskell.plugin.hlint.diagnosticsOn": false,
"haskell.plugin.importLens.codeActionsOn": false,
"haskell.plugin.importLens.codeLensOn": false,
"haskell.plugin.moduleName.globalOn": false,
"haskell.plugin.pragmas.codeActionsOn": false,
"haskell.plugin.pragmas.completionOn": false,
"haskell.plugin.qualifyImportedNames.globalOn": false,
"haskell.plugin.refineImports.codeActionsOn": false,
"haskell.plugin.refineImports.codeLensOn": false,
"haskell.plugin.rename.globalOn": false,
"haskell.plugin.retrie.globalOn": false,
"haskell.plugin.splice.globalOn": false,
"haskell.plugin.tactics.codeActionsOn": false,
"haskell.plugin.tactics.codeLensOn": false,
"haskell.plugin.tactics.config.proofstate_styling": false,
"haskell.plugin.tactics.hoverOn": false,
"haskell.manageHLS": "GHCup",
"haskell.toolchain": {
},
"haskell.trace.server": "messages",
"haskell.trace.client": "debug",
"haskell.upgradeGHCup": false,
"haskell.plugin.hlint.config.flags": [
],
}
The VSC terminal seems to have the ob shell context
what do you mean with context? The only thing that should matter is the PATH. That you can also change in VSCode settings: https://github.com/haskell/vscode-haskell#stackcabalghc-can-not-be-found
Sorry for being imprecise - yes, I was talking about the PATH. I updated the path in the settings as shown in the link (had tried that and other things prior), but starting HLS from inside VSC causes the same error. The name of the option made me think that maybe the supplied PATH is only used when actually calling HLS, but things like cabal exec -v0 -- ghc --print-libdir
might not get the supplied PATH.
2022-06-16 14:36:12.2280000 [client] INFO Executing 'haskell-language-server-wrapper --project-ghc-version' in cwd '/home/me/sim21s'
2022-06-16 14:36:13.5130000 [client] DEBUG Execution of 'haskell-language-server-wrapper --project-ghc-version' terminated with code 1
2022-06-16 14:36:13.5130000 [client] ERROR Error executing 'haskell-language-server-wrapper --project-ghc-version' with error code 1
2022-06-16 14:36:13.5130000 [client] ERROR stderr: Found "/home/me/sim21s/hie.yaml" for "/home/me/sim21s/a"
Failed to get project GHC version: CradleError {cradleErrorDependencies = [], cradleErrorExitCode = ExitFailure 1, cradleErrorStderr = ["Error when calling cabal exec -v0 -- ghc --print-libdir","","cabal: Could not resolve dependencies:\n[__0] trying: backend-0.1 (user goal)\n[__1] unknown package: obelisk-route (dependency of backend)\n[__1] fail (backjumping, conflict set: backend, obelisk-route)\nAfter searching the rest of the dependency tree exhaustively, these were the\ngoals I've had most trouble fulfilling: backend, obelisk-route\n\n"]}
How did you change the PATH? You're only giving half of the information.
I changed it to this (followed by VSC restart for good measure):
"haskell.serverEnvironment": {
"PATH": "${HOME}/.ghcup/bin:$PATH"
},
Sanity check:
me@LAPTOP-MNLASFML:~$ ${HOME}
-bash: /home/me: Is a directory
me@LAPTOP-MNLASFML:~$ ls ~/.ghcup/bin/
cabal ghci-9.2 haskell-language-server-9.2.2~1.7.0.0 hsc2hs-8.6.5 (and so on...)
I changed it to this (followed by VSC restart for good measure):
"haskell.serverEnvironment": { "PATH": "${HOME}/.ghcup/bin:$PATH" },
Sanity check:
me@LAPTOP-MNLASFML:~$ ${HOME} -bash: /home/me: Is a directory
me@LAPTOP-MNLASFML:~$ ls ~/.ghcup/bin/ cabal ghci-9.2 haskell-language-server-9.2.2~1.7.0.0 hsc2hs-8.6.5 (and so on...)
I was talking about the PATH changes that ob shell introduces. That certainly is not ghcup bin dir.
Oh, allright! I will provide the diff introduced by ob shell. Sorry for this information-extracting exchange, I did not expect to supply this information as I opened this as an feature request - but if I get it working withouth code change, all the better :)
The complete path with some line breaks sed
ed in, marked the last path that came from ob shell, diffing was done in VSC.
PATH=.:
/nix/store/q4phq8i3m50xkmp9whnshqfgvizl3yv4-ghc-8.6.5-with-packages/bin:
/nix/store/6i74nzn8sl871mvqnpg1rdg650gqw47f-pretty-show-1.10/bin:
/nix/store/3zzh2sf9h465c9vhy6m1i4w0h3dk0zln-build-tools-wrapper/bin:
/nix/store/m40wl6v6ayalys7l5x5iqif6qwjj1dsx-patchelf-0.12/bin:
/nix/store/ryy81g8zv6c8fh0j10m6fdynrgrn239k-gcc-wrapper-9.3.0/bin:
/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/bin:
/nix/store/ddmdl1fin14hpjvssa7b933661y3xgxg-glibc-2.31-74-bin/bin:
/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:
/nix/store/h8ibzi1f489avmhcz754chnrgr3dysjr-binutils-wrapper-2.31.1/bin:
/nix/store/vfqlryhvm8063hs7ax9k2vb8wmch5v0v-binutils-2.31.1/bin:
/nix/store/ddmdl1fin14hpjvssa7b933661y3xgxg-glibc-2.31-74-bin/bin:
/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:
/nix/store/2dfap74q83z6q1kc9ha6ldl4nmqhmc9w-ncurses-6.2/bin:
/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:
/nix/store/ax8vv1ds6l81jx8cmflx3fvcl9jdxd2w-findutils-4.7.0/bin:
/nix/store/m87blzdbjqhj1dghl5l2dqqnl9dhvarz-diffutils-3.7/bin:
/nix/store/gdr4s4xx41n8krk9carr8amvncy8x3p3-gnused-4.8/bin:
/nix/store/rxkghln0km9axapv94iz3pcsln6ricms-gnugrep-3.4/bin:
/nix/store/b9j6qhmxpwfvga2bfxn1khjrv3v3qxg7-gawk-5.1.0/bin:
/nix/store/k6ssslsxmvndgm056k7x4s75390sjfkz-gnutar-1.32/bin:
/nix/store/2hh9fld5r11zhp3697pzjwmqag76yc54-gzip-1.10/bin:
/nix/store/6v59a9iszrs0kxk1b79v7fasn9bwi79q-bzip2-1.0.6.0.1-bin/bin:
/nix/store/7fqqkrz6m11793cw7by8wbn2q87za8ny-gnumake-4.3/bin:
/nix/store/9ywr69qi622lrmx5nn88gk8jpmihy0dz-bash-4.4-p23/bin:
/nix/store/5vpsaqjazidyfrpjx2z137jmqwn3f2ai-patch-2.7.6/bin:
/nix/store/n5xz5y5wazbhrwa9s9cyv52dabx9qxsq-xz-5.2.5-bin/bin:
/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:
/nix/store/zpnc68vwmkr1rzjsppdsskbm1v4clcpw-git-2.29.3/bin:
/nix/store/gysnvgyj8dvscnbsb0mjchc0a03k255h-nix-prefetch-git/bin:
/nix/store/i7xklsrp3rlx01wk41i8z091s9vg6bka-openssh-8.5p1/bin:
/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:
/nix/store/zpnc68vwmkr1rzjsppdsskbm1v4clcpw-git-2.29.3/bin:
/nix/store/gysnvgyj8dvscnbsb0mjchc0a03k255h-nix-prefetch-git/bin:
/nix/store/i7xklsrp3rlx01wk41i8z091s9vg6bka-openssh-8.5p1/bin: // Last entry that is additional in ob shell
/home/me/.nix-profile/bin:
/home/me/.local/bin:
/home/me/.cabal/bin:
/home/me/.ghcup/bin:
/usr/local/sbin:
/usr/local/bin:
/usr/sbin:
/usr/bin:
/sbin:
/bin:
/usr/games:
/usr/local/games:
/usr/lib/wsl/lib:
/mnt/c/Windows/system32:
/mnt/c/Windows:
/mnt/c/Windows/System32/Wbem:
/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:
/mnt/c/Windows/System32/OpenSSH/:
/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:
/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:
/mnt/c/WINDOWS/system32:
/mnt/c/WINDOWS:
/mnt/c/WINDOWS/System32/Wbem:
/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:
/mnt/c/WINDOWS/System32/OpenSSH/:
/mnt/c/Program Files/WireGuard/:
/mnt/c/Users/me/AppData/Local/Microsoft/WindowsApps:
/mnt/c/Users/me/AppData/Local/Programs/Microsoft VS Code/bin:
/mnt/c/ghcup/bin:
/snap/bin
This might also be helpful (first running ob shell
, then ghcup whereis ghcup
):
[nix-shell:~/myProject]$ ghcup whereis ghcup
/home/me/.ghcup/bin/ghcup
Try to set haskell.manageHLS
to PATH
and then start vscode from within the ob shell.
It led to a new error in Visual Studio Code - the server seems to start now?
Error: Couldn't start client Haskell (myProject)
Logs:
2022-06-16 15:46:13.3100000 [client] INFO Writing client log to file /home/me/logFileHLS
2022-06-16 15:46:13.3100000 [client] DEBUG Environment variables:
2022-06-16 15:46:13.3100000 [client] DEBUG PATH: /home/me/.vscode-server/bin/30d9c6cd9483b2cc586687151bcbcd635f373630/bin/remote-cli:.:/nix/store/q4phq8i3m50xkmp9whnshqfgvizl3yv4-ghc-8.6.5-with-packages/bin:/nix/store/6i74nzn8sl871mvqnpg1rdg650gqw47f-pretty-show-1.10/bin:/nix/store/3zzh2sf9h465c9vhy6m1i4w0h3dk0zln-build-tools-wrapper/bin:/nix/store/m40wl6v6ayalys7l5x5iqif6qwjj1dsx-patchelf-0.12/bin:/nix/store/ryy81g8zv6c8fh0j10m6fdynrgrn239k-gcc-wrapper-9.3.0/bin:/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/bin:/nix/store/ddmdl1fin14hpjvssa7b933661y3xgxg-glibc-2.31-74-bin/bin:/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:/nix/store/h8ibzi1f489avmhcz754chnrgr3dysjr-binutils-wrapper-2.31.1/bin:/nix/store/vfqlryhvm8063hs7ax9k2vb8wmch5v0v-binutils-2.31.1/bin:/nix/store/ddmdl1fin14hpjvssa7b933661y3xgxg-glibc-2.31-74-bin/bin:/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:/nix/store/2dfap74q83z6q1kc9ha6ldl4nmqhmc9w-ncurses-6.2/bin:/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:/nix/store/ax8vv1ds6l81jx8cmflx3fvcl9jdxd2w-findutils-4.7.0/bin:/nix/store/m87blzdbjqhj1dghl5l2dqqnl9dhvarz-diffutils-3.7/bin:/nix/store/gdr4s4xx41n8krk9carr8amvncy8x3p3-gnused-4.8/bin:/nix/store/rxkghln0km9axapv94iz3pcsln6ricms-gnugrep-3.4/bin:/nix/store/b9j6qhmxpwfvga2bfxn1khjrv3v3qxg7-gawk-5.1.0/bin:/nix/store/k6ssslsxmvndgm056k7x4s75390sjfkz-gnutar-1.32/bin:/nix/store/2hh9fld5r11zhp3697pzjwmqag76yc54-gzip-1.10/bin:/nix/store/6v59a9iszrs0kxk1b79v7fasn9bwi79q-bzip2-1.0.6.0.1-bin/bin:/nix/store/7fqqkrz6m11793cw7by8wbn2q87za8ny-gnumake-4.3/bin:/nix/store/9ywr69qi622lrmx5nn88gk8jpmihy0dz-bash-4.4-p23/bin:/nix/store/5vpsaqjazidyfrpjx2z137jmqwn3f2ai-patch-2.7.6/bin:/nix/store/n5xz5y5wazbhrwa9s9cyv52dabx9qxsq-xz-5.2.5-bin/bin:/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:/nix/store/zpnc68vwmkr1rzjsppdsskbm1v4clcpw-git-2.29.3/bin:/nix/store/gysnvgyj8dvscnbsb0mjchc0a03k255h-nix-prefetch-git/bin:/nix/store/i7xklsrp3rlx01wk41i8z091s9vg6bka-openssh-8.5p1/bin:/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:/nix/store/zpnc68vwmkr1rzjsppdsskbm1v4clcpw-git-2.29.3/bin:/nix/store/gysnvgyj8dvscnbsb0mjchc0a03k255h-nix-prefetch-git/bin:/nix/store/i7xklsrp3rlx01wk41i8z091s9vg6bka-openssh-8.5p1/bin:/home/me/.nix-profile/bin:/home/me/.local/bin:/home/me/.cabal/bin:/home/me/.ghcup/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/WireGuard/:/mnt/c/Users/me/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/me/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/ghcup/bin:/snap/bin
2022-06-16 15:46:13.3110000 [client] INFO Finding haskell-language-server
2022-06-16 15:46:13.3350000 [client] INFO Searching for server executables haskell-language-server-wrapper,haskell-language-server in $PATH
2022-06-16 15:46:13.3350000 [client] INFO $PATH environment variable: /home/me/.vscode-server/bin/30d9c6cd9483b2cc586687151bcbcd635f373630/bin/remote-cli:.:/nix/store/q4phq8i3m50xkmp9whnshqfgvizl3yv4-ghc-8.6.5-with-packages/bin:/nix/store/6i74nzn8sl871mvqnpg1rdg650gqw47f-pretty-show-1.10/bin:/nix/store/3zzh2sf9h465c9vhy6m1i4w0h3dk0zln-build-tools-wrapper/bin:/nix/store/m40wl6v6ayalys7l5x5iqif6qwjj1dsx-patchelf-0.12/bin:/nix/store/ryy81g8zv6c8fh0j10m6fdynrgrn239k-gcc-wrapper-9.3.0/bin:/nix/store/fvf3qjqa5qpcjjkq37pb6ypnk1mzhf5h-gcc-9.3.0/bin:/nix/store/ddmdl1fin14hpjvssa7b933661y3xgxg-glibc-2.31-74-bin/bin:/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:/nix/store/h8ibzi1f489avmhcz754chnrgr3dysjr-binutils-wrapper-2.31.1/bin:/nix/store/vfqlryhvm8063hs7ax9k2vb8wmch5v0v-binutils-2.31.1/bin:/nix/store/ddmdl1fin14hpjvssa7b933661y3xgxg-glibc-2.31-74-bin/bin:/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:/nix/store/2dfap74q83z6q1kc9ha6ldl4nmqhmc9w-ncurses-6.2/bin:/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:/nix/store/ax8vv1ds6l81jx8cmflx3fvcl9jdxd2w-findutils-4.7.0/bin:/nix/store/m87blzdbjqhj1dghl5l2dqqnl9dhvarz-diffutils-3.7/bin:/nix/store/gdr4s4xx41n8krk9carr8amvncy8x3p3-gnused-4.8/bin:/nix/store/rxkghln0km9axapv94iz3pcsln6ricms-gnugrep-3.4/bin:/nix/store/b9j6qhmxpwfvga2bfxn1khjrv3v3qxg7-gawk-5.1.0/bin:/nix/store/k6ssslsxmvndgm056k7x4s75390sjfkz-gnutar-1.32/bin:/nix/store/2hh9fld5r11zhp3697pzjwmqag76yc54-gzip-1.10/bin:/nix/store/6v59a9iszrs0kxk1b79v7fasn9bwi79q-bzip2-1.0.6.0.1-bin/bin:/nix/store/7fqqkrz6m11793cw7by8wbn2q87za8ny-gnumake-4.3/bin:/nix/store/9ywr69qi622lrmx5nn88gk8jpmihy0dz-bash-4.4-p23/bin:/nix/store/5vpsaqjazidyfrpjx2z137jmqwn3f2ai-patch-2.7.6/bin:/nix/store/n5xz5y5wazbhrwa9s9cyv52dabx9qxsq-xz-5.2.5-bin/bin:/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:/nix/store/zpnc68vwmkr1rzjsppdsskbm1v4clcpw-git-2.29.3/bin:/nix/store/gysnvgyj8dvscnbsb0mjchc0a03k255h-nix-prefetch-git/bin:/nix/store/i7xklsrp3rlx01wk41i8z091s9vg6bka-openssh-8.5p1/bin:/nix/store/vr96j3cxj75xsczl8pzrgsv1k57hcxyp-coreutils-8.31/bin:/nix/store/zpnc68vwmkr1rzjsppdsskbm1v4clcpw-git-2.29.3/bin:/nix/store/gysnvgyj8dvscnbsb0mjchc0a03k255h-nix-prefetch-git/bin:/nix/store/i7xklsrp3rlx01wk41i8z091s9vg6bka-openssh-8.5p1/bin:/home/me/.nix-profile/bin:/home/me/.local/bin:/home/me/.cabal/bin:/home/me/.ghcup/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/WireGuard/:/mnt/c/Users/me/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/me/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/ghcup/bin:/snap/bin
2022-06-16 15:46:13.3480000 [client] INFO Found server executable in $PATH: haskell-language-server-wrapper
2022-06-16 15:46:13.3480000 [client] INFO Activating the language server in working dir: /home/me/myProject (the workspace folder)
2022-06-16 15:46:13.3490000 [client] INFO run command: haskell-language-server-wrapper --lsp -d -l ~/logFileHLS
2022-06-16 15:46:13.3490000 [client] INFO debug command: haskell-language-server-wrapper --lsp -d -l ~/logFileHLS
2022-06-16 15:46:13.3490000 [client] INFO server environment variables:
2022-06-16 15:46:13.3490000 [client] INFO PATH=${HOME}/.ghcup/bin:$PATH
2022-06-16 15:46:13.3490000 [client] DEBUG document selector patten: /home/me/myProject/**/*
2022-06-16 15:46:13.3570000 [client] INFO Starting language server
Btw, this warning is shown when running ob shell
:
me@LAPTOP-MNLASFML:~/myProject$ ob shell
./.obelisk/impl: command not cached, building ...
✔ Built on ./.obelisk/impl [command]
warning: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I), at (string):1:9; will use bash from your environment
[nix-shell:~/myProject]$ code .
Since the project builds fine, I have not yet spend much time to fix this warning.
Well, my guess is that the ob shell exposes a ghcjs binary. But HLS is linked against the GHC API and probably doesn't know how to deal with any of this: https://github.com/haskell/haskell-language-server/issues/349
Where does your haskell-language-server binary come from? It has to be compiled with the same GHC version that your project will be compiled with, because otherwise you'll run into ABI compat issues.
Hmm, it might the second issue! haskell-language-server came from ghcup, but maybe I made an mistake.
This is my current state:
[nix-shell:~/myProject]$ ghcup install ghc 8.6.5
[ Warn ] GHC ver 8.6.5 already installed; if you really want to reinstall it, you may want to run 'ghcup install ghc --force 8.6.5'
[nix-shell:~/myProject]$ ghcup install hls --force 1.7.0.0
...
[ Info ] Installing HLS
[ Info ] HLS installation successful
[ Info ] This is just the server part of your LSP configuration. Consult the README on how to
[ ... ] configure HLS, your project and your LSP client in your editor:
[ ... ] https://github.com/haskell/haskell-language-server/blob/master/README.md
[ ... ]
This happens when calling haskell-language-server:
[nix-shell:~/myProject]$ haskell-language-server-wrapper --lsp -d
Found "/home/me/myProject/hie.yaml" for "/home/me/myProject/a"
Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.7.0.0 x86_64 ghc-9.2.2
Current directory: /home/me/myProject
Operating system: linux
Arguments: ["--lsp","-d"]
Cradle directory: /home/dan/myProject
Cradle type: Cabal
Tool versions found on the $PATH
cabal: 3.2.0.0
stack: 2.7.5
ghc: 8.6.5
Consulting the cradle to get project GHC version...
Project GHC version: 8.6.5
haskell-language-server exe candidates: ["haskell-language-server-8.6.5","haskell-language-server"]
Launching haskell-language-server exe at:/home/me/.ghcup/bin/haskell-language-server-8.6.5
GHC ABIs don't match!
Expected: Cabal-2.4.0.1:f49162002f0093dea32d0e52b9c3e61a ... 79184cc068d874
Content-Length: 203
{"jsonrpc":"2.0", "method":"window/showMessage", "params": {"type": 1, "message": "Couldn't find a working/matching GHC installation. Consider installing ghc-8.6.5 via ghcup or build HLS from source."}}
So haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.7.0.0 x86_64 ghc-9.2.2
seems certainly wrong. But I don't know how build haskell-language-server with ghc 8.6.5. I read that hls 1.7.0.0 supports ghc 8.6.5 and just assumed that it would work out. Can you tell me the next steps?
ghcup compile hls -v 1.7.0.0 -j10 --ghc 8.6.5
Thank you for the command! I think I managed to overcome the ABI issues, but I now see a new error (however one that I have never seen before, nice!)
Symptom: The top line of my Haskell files is underlined red, reporting: "Couldn't execute cabal exec -v0 -- ghc --print-libdir" by cradle. (Similar to https://github.com/haskell/haskell-language-server/issues/1693 and https://github.com/haskell/vscode-haskell/issues/538)
I already tried to add the path to ghc by calling export PATH=/home/me/.ghcup/ghc/8.6.5/bin/ghc:$PATH
in the ob shell, and I added that same path to ghc to the PATH in the server environment settings, both did not solve the problem.
This is my current setup:
The command works in ob shell:
[nix-shell:~/sim21s]$ cabal exec -v0 -- ghc --print-libdir
/nix/store/q4phq8i3m50xkmp9whnshqfgvizl3yv4-ghc-8.6.5-with-packages/lib/ghc-8.6.5
I also appended this output in the PATH of haskell.serverEnvironment, but it did not seem to help.
My hie.yaml:
cradle:
cabal:
- path: "backend/src"
component: "lib:backend"
- path: "common/src"
component: "lib:common"
- path: "frontend/src"
component: "lib:frontend"
dependencies:
- default.nix
- backend/backend.cabal
- common/common.cabal
- frontend/frontend.cabal
My vscode-haskell settings:
{
"workbench.colorTheme": "Default Light+",
"haskell.plugin.alternateNumberFormat.globalOn": false,
"haskell.plugin.callHierarchy.globalOn": false,
"haskell.plugin.changeTypeSignature.globalOn": false,
"haskell.plugin.class.globalOn": false,
"haskell.plugin.eval.config.diff": false,
"haskell.plugin.eval.globalOn": false,
"haskell.plugin.ghcide-code-actions-bindings.globalOn": false,
"haskell.plugin.ghcide-code-actions-fill-holes.globalOn": false,
"haskell.plugin.ghcide-code-actions-imports-exports.globalOn": false,
"haskell.plugin.ghcide-code-actions-type-signatures.globalOn": false,
"haskell.plugin.ghcide-completions.config.snippetsOn": false,
"haskell.plugin.ghcide-completions.globalOn": false,
"haskell.plugin.ghcide-hover-and-symbols.hoverOn": false,
"haskell.plugin.ghcide-hover-and-symbols.symbolsOn": false,
"haskell.plugin.ghcide-type-lenses.config.mode": "exported",
"haskell.plugin.ghcide-type-lenses.globalOn": false,
"haskell.plugin.haddockComments.globalOn": false,
"haskell.plugin.hlint.codeActionsOn": false,
"haskell.plugin.hlint.diagnosticsOn": false,
"haskell.plugin.importLens.codeActionsOn": false,
"haskell.plugin.importLens.codeLensOn": false,
"haskell.plugin.moduleName.globalOn": false,
"haskell.plugin.pragmas.codeActionsOn": false,
"haskell.plugin.pragmas.completionOn": false,
"haskell.plugin.qualifyImportedNames.globalOn": false,
"haskell.plugin.refineImports.codeActionsOn": false,
"haskell.plugin.refineImports.codeLensOn": false,
"haskell.plugin.rename.globalOn": false,
"haskell.plugin.retrie.globalOn": false,
"haskell.plugin.splice.globalOn": false,
"haskell.plugin.tactics.codeActionsOn": false,
"haskell.plugin.tactics.codeLensOn": false,
"haskell.plugin.tactics.config.proofstate_styling": false,
"haskell.plugin.tactics.hoverOn": false,
"haskell.trace.server": "messages",
"haskell.trace.client": "debug",
"haskell.upgradeGHCup": false,
"haskell.serverEnvironment": {
"PATH": "/home/me/.ghcup/ghc/8.6.5/bin:${HOME}/.ghcup/bin:$PATH"
},
"haskell.logFile": "~/logFileHLS",
"haskell.serverExecutablePath": "/home/me/.ghcup/bin/haskell-language-server-8.6.5~1.7.0.0",
}
I don't understand why you keep prepending ghcup paths to your PATH. Your ob shell provides ghc via nix (and they should take precedence). You're mixing up everything.
I am not experienced at haskell tooling ¯\(ツ)/¯ And honestly, I just want to write programs and not deal with these kind of problems, and given that the vscode complains about not being able to cabal exec -v0 -- ghc --print-libdir
- I don't mind throwing anything that might remotely help onto the PATH. Heck, I might even sacrifice a medium-sized animal at that point. I just want to make this haskell extension happy and give it all the ghc, cabal, and whatever else it needs, no matter where it comes from.
This does not seem to fare much better (and should not be necessary when starting vscode from within ob shell, which I do):
"haskell.serverEnvironment": {
"PATH": "/nix/store/q4phq8i3m50xkmp9whnshqfgvizl3yv4-ghc-8.6.5-with-packages/bin:$PATH"
},
[nix-shell:~/myProject]$ ls /nix/store/q4phq8i3m50xkmp9whnshqfgvizl3yv4-ghc-8.6.5-with-packages/bin
clientsession-generate ghci-8.6.5 haddock-ghc-8.6.5 obelisk-asset-manifest-generate runghc warp
ghc ghc-pkg hp2ps obelisk-asset-th-generate runghc-8.6.5
ghc-8.6.5 ghc-pkg-8.6.5 hpc ppsh runhaskell
ghci haddock hsc2hs readme wai-websockets-example
If you want someone else to test this, provide clear instructions on how to reproduce. I don't use nix and I have never used obelisk either.
I do not currently. I will when I spend time looking into this again. But then I will likely fill out a bug report with reproduction steps and all of that.
This issue was opened by me since I thought this feature might be easy to implement and not only useful for me. But it is possible that it might not help the problem at hand. So I am closing this feature request.
Thank you for your time and answers, it felt good making at least some progress getting vscode-haskell to work with obelisk!
Note: one way to get an older version of HLS (0.2.0.0 IIRC) working with Obelisk is to add HLS to the shellToolOverrides
argument to Obelisk's project
function like so:
smithyProject = project ./. ({ pkgs, ... }: {
shellToolOverrides = ghc: super: {
inherit (pkgs.haskell.packages.ghc865) haskell-language-server;
};
});
After that, inside VS Code set haskell.manageHLS
to PATH. Then enter ob shell
and inside the shell start VS Code in the current folder: code .
.
VS Code should then pick up the haskell-language-server binary specified above.
Thank you for this project! :)
Is your feature request related to a problem? Please describe.
I did not manage to run HLS when developing with https://github.com/obsidiansystems/obelisk (a reflex framework that uses nix under the hood). I ran the commands that HLS tried to run outside of VSC and they worked when I ran them in the
ob shell
(an obelisk-specific wrapper around anix-shell
.) This is the command that fails:cabal exec -v0 -- ghc --print-libdir
(seems to be a sanity check before HLS is supposed to start.)I saw that this extension already offers the option to run in a custom folder. However, I would also need to run in
ob shell
to have the correct environment variables.Describe the solution you'd like
Similar to the Run-In-A-Custom-Folder-Option, I would like to have a Fire-Up-This-Custom-Shell-And-Do-All-Your-Work-There-Option.
In my case, I would enter
ob shell
as the input to the option and expectcabal exec -v0 -- ghc --print-libdir
to work for this extension.Since scenarios like mine should be the exception rather than the rule, some hint would be helpful that this option should rarely be needed.
Describe alternatives you've considered
I did not manage to find alternatives, but I noticed that the VSC terminal seems to pick up the context correctly, i.e. it runs
cabal exec -v0 -- ghc --print-libdir
just fine.