lsp

Casey 2025-04-10T14:28:55.741119Z

I could use some assistance troubleshooting emacs + lsp-mode + clojure-lsp. Details in the thread.

Casey 2025-04-11T07:58:21.598099Z

I just installed and booted doom, and it doesn't have this problem 😕

ericdallo 2025-04-11T11:57:55.793989Z

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

2025-04-11T15:24:49.503669Z

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

☝️ 1
Casey 2025-04-11T16:30:53.090519Z

Nope I'm using Linux (nixos), and in any case I was launching emacs at my normal shell.

Casey 2025-04-11T16:31:50.295309Z

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

Casey 2025-04-10T14:29:32.689669Z

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.1

Casey 2025-04-10T14:42:06.565219Z

Things 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.

Casey 2025-04-10T14:42:35.881459Z

...even after a restart where lsp-log-io is nil 🤦‍♂️

2025-04-10T16:01:13.299319Z

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

ericdallo 2025-04-10T16:28:12.717659Z

> 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

ericdallo 2025-04-10T16:28:24.771359Z

clojure-lsp logs looks correct

Casey 2025-04-11T05:52:47.048289Z

> 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.

Casey 2025-04-11T05:55:35.317389Z

> 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.

Casey 2025-04-11T06:08:35.433539Z

I flipped debug-on-error on and this appears when the vfork happens:

Casey 2025-04-11T06:08:47.098079Z

gosh that isn't easy on the eyes.. the path to clojure-lsp in that log does exist and work

Casey 2025-04-11T06:09:27.018089Z

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.

Casey 2025-04-11T06:57:51.095999Z

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.