I could use some assistance troubleshooting emacs + lsp-mode + clojure-lsp. Details in the thread.
I just installed and booted doom, and it doesn't have this problem 😕
yeah, pretty weird, I don't know why the bash -c helps with that, but I suspect doom does something more with shell sessions or envs loaded by emacs
Are you using MacOS? If emacs was launching with a different environment then what you start a shell, and that environment is missing something, that might explain why adding the call to bash solves things, and that is an easy state to end up in on MacOS because of how it launches apps
Nope I'm using Linux (nixos), and in any case I was launching emacs at my normal shell.
The bash/vfork thing was so strange because it was triggered by setting lsp-log-io once. Before that it could call the process without issue
clojure-lsp isn't working properly in my emacs and I am not sure why.
M-X lsp-rename (while the point is over a symbol in a clj buffer):
lsp--get-symbol-to-rename: The connected server(s) doesn't support renaming
(lsp-find-definition also doesn't work)
M-X lsp-doctor:
Checking for Native JSON support: OK
Check emacs supports `read-process-output-max': OK
Check `read-process-output-max' default has been changed from 4k: OK
Byte compiled against Native JSON (recompile lsp-mode if failing when Native JSON available): OK
`gc-cons-threshold' increased?: OK
Using `plist' for deserialized objects? (refer to ): OPTIONAL
Using emacs 28+ with native compilation?: OK
M-X lsp-workspace-restart:
LSP :: Restarting LSP in buffer app.members.index.view
LSP :: Connected to [clojure-lsp:162526/starting /home/ramblurr/src/my-project].
the *lsp-log* buffer outputs:
Command "semgrep lsp" is not present on the path.
Command "semgrep lsp" is not present on the path.
Found the following clients for /home/ramblurr/src/my-project/src/clj/app/members/index/view.clj: (server-id clojure-lsp, priority 0)
The following clients were selected based on priority: (server-id clojure-lsp, priority 0)
M-X lsp-clojure-server-log:
;; First it hangs for some seconds then in *Messages*
lsp-request: Timeout while waiting for response. Method: clojure/serverInfo/raw
M-X lsp-clojure-server-info:
Hangs for awhile, then returns, nothing visibly happens, and none of the buffers seem to have any new output in them. Specifically *clojure-lsp* is empty
M-X lsp-describe-session:
[-] /home/ramblurr/src/my-project
`-[-] clojure-lsp:179192/starting
|-[-] Buffers
| `-[+] app.members.index.view
`-[+] Capabilities
Log files
/tmp/clojure-lsp.16015880993202949902.out
$ cat /tmp/clojure-lsp.16015880993202949902.out
2025-04-10T14:17:18.555Z INFO [clojure-lsp.server:643] - [SERVER] Starting server...
2025-04-10T14:17:18.559Z DEBUG [clojure-lsp.nrepl:21] - nrepl not found, skipping nrepl server start...
2025-04-10T14:17:18.560Z INFO [clojure-lsp.server:524] - Initializing...
/tmp/clojure-lsp.out - rather large, but nothing interesting? Attached.
Other stuff I tried
- Manual interaction at cli as described in "Server is not initializing" from troubleshooting docs works.
- clojure-lsp diagnostics from the cli at the root of my project lists a bunch of clj-kondo style linting errors
- I am using clojure-lsp on nixos, installed from nixos-unstable:
$ clojure-lsp --version
clojure-lsp 2025.03.07-17.42.36
clj-kondo 2025.02.20
- lsp-mode is running the commit from yesterday: https://github.com/emacs-lsp/lsp-mode/commit/d9d4a5ac0c47d040f2c2b3c3c63680a262c9685f
- emacs is version 30.1Things are getting worse. I did M-X set-variable to set lsp-log-io to t, but this outputs File mode specification error: (file-missing Doing vfork No such file or directory) and now, clojure-mode is broken with the same error.
...even after a restart where lsp-log-io is nil 🤦♂️
are you using doom emacs? if you search the web for the vfork error there is a lot of chatter about it, not sure if anyone has nailed down a fix for it, some people report upgrading doom fixes it
> Connected to [clojure-lsp:162526/starting /home/ramblurr/src/my-project]. check if this is the correct project root but overall looks like a lsp-mode issue, probably a misconfigured project root or something like that
clojure-lsp logs looks correct
> are you using doom emacs?
I'm not using doom 😞
So strange. The vfork error appeared when iset lsp-log-io to t, and even after restarts and straight rebuilds it persisted. Only disabling lsp-mode resolved it. Enabling it again brings it back 😞
I don't think I have a crazy emacs config its just corgi + a handful of extra use-packages.
> check if this is the correct project root I can't check now because lsp-mode is broken with the vfork thing, but I am fairly certain it was correct. There are no other deps.edn in that dir, nor parent dirs up to the root.
I flipped debug-on-error on and this appears when the vfork happens:
gosh that isn't easy on the eyes.. the path to clojure-lsp in that log does exist and work
lsp--start-workspace(#s(lsp-session :folders ("/home/ramblurr/src/clojure-playground/another-project" "/home/ramblurr/src/my-project") :folders-blocklist nil :....)
Why is that other project in there? No buffers are open from that project.
Edit: Red herring. M-X lsp-workspace-remove-all-folders got rid of it, now its just the one my-project and the vfork error persists.Ok. What a wild ride. I solved the vfork problem with:
(setq lsp-clojure-custom-server-command '("bash" "-c" "/etc/profiles/per-user/ramblurr/bin/clojure-lsp"))
Why does this work? I do not know. Before it was trying to run the binary directly, wrapping it in bash -c works. Anyone know why?
So lsp-mode was starting/initing again, but still most features were broken.
I removed all configurations to my lsp-mode use-package block (except the custom server command), and features worked. I slowly added back my (few) customizations until it broke. The culprit was (setq lsp-use-plists nil). I had explicitly disabled this while debugging lsp-mode (I swear I was having issues before I added this). I read the lsp-mode docs and (re-)discovered there is also an env var LSP_USE_PLISTS that I had long ago set to true. Aligning the custom var and env var (to true) seems to have solved my problems.