haskell / haskell-language-server

Official haskell ide support via language server (LSP). Successor of ghcide & haskell-ide-engine.
Apache License 2.0
2.65k stars 355 forks source link

HLS broken within a particular dir, but works ok if the dir is renamed #1614

Closed madjestic closed 3 years ago

madjestic commented 3 years ago

Hey guys,

I've got this situation when HLS fails to run properly in a particular dir. If I rename this dir, build the very same project and run haskell-language-server, it works correctly. It looks like there's some cache/config that HLS uses to keep track of the projects and that particular dir somehow fails. I would like to delete such cach or config. Could you tell me where HLS stores it?

I tried cleaning up the $ .cache/ghcide and $ .cache/hie-bios, as well as deleting $ .stack (I built hls with cabal by the way, so maybe that makes no sense), that did not help: restarting the project with hls, I did not get the dialogue asking whether I want to import the project into lsp-session-folders (which would normally happen when starting a new project than HLS does not know about), so it looks like HLS still knows about that dir and keeps failing.

Your environment

Output of haskell-language-server --probe-tools or haskell-language-server-wrapper --probe-tools:

 $ haskell-language-server --probe-tools
haskell-language-server version: 1.0.0.0 (GHC: 8.10.3) (PATH: /home/madjestic/.cabal/store/ghc-8.10.3/haskell-language-server-1.0.0.0-32caa98a41dbf1057e8c030dc754d9fe40aafd2d1d9c35d918c2843acd3d7214/bin/haskell-language-server)
Tool versions found on the $PATH
cabal:      3.2.0.0
stack:      2.5.1.1
ghc:        8.10.3

Which lsp-client do you use: emacs

just some exercise in ML

name:                  mlex1
version:               0.1.0.0
synopsis:              Coursera Machine Learning Excercise
author:                madjestic
maintainer:            madjestic13@gmail.com
copyright:             Vladimir Lopatin
category:              Math
build-type:            Simple
cabal-version:         >=2.0

extra-source-files:    CHANGELOG.md
                       README.md

executable mlex1
  main-is:             Main.hs
  hs-source-dirs:
                       app
  ghc-options:        -threaded -O2
  --cpp-options:         -DDEBUG
  build-depends:
                       base                ^>= 4.14.1.0

  other-modules:
                       Paths_mlex1
  default-language:
                       Haskell2010

test-suite mlex1-test
  default-language:    Haskell2010
  type:                exitcode-stdio-1.0
  hs-source-dirs:      test
  main-is:             Test.hs
  build-depends:       base                ^>= 4.14.1.0
                     , hmatrix             ^>= 0.20.0.0

Thanks, Vlad.

jneira commented 3 years ago

Hi, thanks for the bug report, it is realy really weird. I assume that if you set the original dir name again the error is reproduced again. It would be good to know how the error was produced at first and the lsp log containing the error: https://github.com/haskell/haskell-language-server#troubleshooting-the-server

jneira commented 3 years ago

Making a search of lsp-session-folders, it seems it is a concept related with emacs lsp-mode: see https://github.com/emacs-lsp/lsp-mode/blob/ed9308e57ff3f3de0adfb2a5036d43852ea1179e/lsp-mode.el#L3467 for example There is no refence in this repo of haskell-lsp about that so i would consider the possibility it is an issue with lsp-mode

madjestic commented 3 years ago

@jneira Thanks for the clue!

It looks like the culprit was the file ~/.emacs.d/.lsp-session-v1. After deleting it, rebuilding, starting the haskell-language-server in the project root and re-opening the project with emacs, I got the lsp-session-folders dialogue popup again and, after choosing the project root, HLS is working correctly.

alanz commented 3 years ago

FYI, the commands to work with this file are lsp-workspace-blacklist-remove, lsp-workspace-folders-add, and lsp-workspace-folders-remove