# Presence of a .git directory breaks Haskell Language Server

**URL:** <https://discourse.haskell.org/t/presence-of-a-git-directory-breaks-haskell-language-server/11861>\
**Category:** Learn\
**Created:** [April 16, 2025, 3:51am UTC](https://discourse.haskell.org/t/presence-of-a-git-directory-breaks-haskell-language-server/11861 "2025-04-16T03:51:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![morphismz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/morphismz/32/5340_2.png) [@morphismz](https://discourse.haskell.org/u/morphismz)\
**Post date:** [April 16, 2025, 3:51am UTC](https://discourse.haskell.org/t/presence-of-a-git-directory-breaks-haskell-language-server/11861/1 "2025-04-16T03:51:22Z")

</div>

I’m running into an odd bug, and I’m not sure how to go about further diagnosing it and fixing it.

In short, the presence of a `.git` directory “breaks” the haskell language server.

I have a cabal project in a directory `.../parent/project` with a cabal file `project.cabal`. When a `.git` directory is present in `parent` (or an even further removed parent directory) , the haskell language server cannot find three specific packages that have been listed in the `project.cabal` file. It can find all others. Additionally, if I remove all dependencies from the `project.cabal` file, the haskell language server still recognizes all those other packages, all of which it no longer should. So it seems that the haskell language server is somehow not reading the cabal file. There is no other cabal file contained in any of the parent directories.

I should note that `cabal run` and `haskell-langauge-server-wrapper` both still work fine, its only the haskell language server as its initiated by eglot (in emacs) that breaks.

When I rename the `.git` file to even just `git`, suddenly haskell language server works properly again.

If I remove all the content of `.git` so that it is an empty directory, the haskell language server still breaks.

If I create a new cabal project inside the directory `parent`, same result.

I have tested this across two different machines, in different parent directories, etc. I have tested this with HLS 2.9.0.1 and 2.10.0.0. I have tested this with GHC 9.10.1 and GHC 9.12.2. The result is the same.

However, I have many other cabal projects residing in git repositories, all of them have the haskell language server working just fine. I cannot for the life of me see a difference between this git repository and any of the others.

Has anybody run into a similar issue or have an idea of how to go about debugging this?

---

<div class="post-metadata">

**Author:** ![ReleaseCandidate](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/releasecandidate/32/2849_2.png) [@ReleaseCandidate](https://discourse.haskell.org/u/ReleaseCandidate)\
**Post date:** [April 16, 2025, 4:05am UTC](https://discourse.haskell.org/t/presence-of-a-git-directory-breaks-haskell-language-server/11861/2 "2025-04-16T04:05:26Z")

</div>

If I understand you correctly and that error only occures in Emacs, it is caused by Emacs’ / eglot’s project handling, which uses a `.git` directory as one of the possibilities to mark a project’s root directory. I don’t use eglot for many other reasons, so I can only say that at least lsp-mode interactively asks for the project’s root if there is no “project” registered yet for the opened file.

---

<div class="post-metadata">

**Author:** ![morphismz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/morphismz/32/5340_2.png) [@morphismz](https://discourse.haskell.org/u/morphismz)\
**Post date:** [April 16, 2025, 4:22am UTC](https://discourse.haskell.org/t/presence-of-a-git-directory-breaks-haskell-language-server/11861/3 "2025-04-16T04:22:23Z")

</div>

I see, that would make sense. Eglot seems to think the project directory is `parent`, not `project`. And when I remove the `.git` file, eglot seems to think the project directory is `project/app`, not `project`. Thank you, I think that identifies the problem. I thought it had to do with HLS, not eglot, mostly because HLS could still find some packages.

It seems like [this question](http://discourse.haskell.org/t/solved-haskell-language-server-basic-setup-for-emacs-eglot/10969/12) runs into the same issue.

Looks like there are two suggestions there that will work, adding a `cabal.project` file at the same level as the `.git` file, or setting the `project-vc-extra-root-markers` variable. The second one worked for me.
