LSP mode race condition when the LSP is provided by nix
- Dominant language
- Emacs Lisp
- Stars
- 22.7k
- Forks
- 3.1k
- Avg merge
- 10h 46m
- Merged PRs (30d)
- 4
Description
### I confirm that...
- [X] I have searched the [issue tracker](https://github.com/doomemacs/doomemacs/issues), [documentation](https://docs.doomemacs.org), [FAQ](https://docs.doomemacs.org/-/faq), [Discourse](https://discourse.doomemacs.org), and [Google](https://google.com), in case this issue has already been reported/resolved.
- [X] I have read "[How to Debug Issues](https://doomemacs.org/d/how2debug)", and will use it to provide as much information about this issue as possible.
- [X] The issue can be reproduced on the **latest** available commit of Doom.
- [X] The issue can be reproduced on a stable release of Emacs, such as 27 or 28. *(Doom does not support development builds like 29+ or any version ending in .50 or .9x)*
### Expected behavior
`doom-emacs` should find the LSP that is available on the `$PATH`.
### Current behavior
When using `doom-emacs` with a project-specific LSP (`haskell-language-server`) managed by `nix` and `direnv`,
1. Open a terminal and navigate to `$PROJECTDIR`.
2. Confirm via the shell (`which haskell-language-server-wrapper`) that the project-specific LSP (or any other project-specific dependency you like) is set up correctly.
3. Launch `emacs` from the same shell.
4. Open a relevant project file and wait for the following sequence of messages in the bottom left / `*Messages*` area to appear:
```
Running direnv in $PROJECTDIR...
Direnv succeeded in $PROJECTDIR
LSP :: The following servers support current file but do not have automatic installation: lsp-haskell
You may find the installation instructions at https://emacs-lsp.github.io/lsp-mode/page/languages.
(If you have already installed the server check *lsp-log*).
```
5. Checking `*lsp-log*` shows
```
Command "haskell-language-server-wrapper --lsp -d -l /tmp/hls.log" is not present on the path.
```
I'm not the first person to encounter this issue: see e.g.
- an earlier post on the `doom-emacs` discord describing the same issue under the same circumstances: https://discord.com/channels/406534637242810369/406554085794381833/933739407192780880
- The solution that did not work for them does not work for me either.
Other (globally installed) LSPs have not and do not currently have the same issue.
### Steps to reproduce
(See above.)
### System Information
https://pastebin.com/dLsytR8c
Contributor guide
Assessment
This issue has not been assessed yet.