LSP only loads when launching zed via cli
Summary
Launching Zed normally does not automatically load necessary LSPs for the project, but using zed [workspace] correctly loads the LSPs.
Steps to trigger the problem:
- Install Zed.
- Open Zed.
- Install the Zed CLI via the menu.
- Open any project with Zed (I've tried TypeScript projects with eslint/prettier/tailwind and a Go project).
- Open a file and note that the primary LSP for the language (TypeScript or Go) does not load.
- Close Zed.
- Open a terminal.
- Open the same project using
zed [workspace]. - Note that immediately upon the workspace loading, the LSP for the language (TypeScript or Go) is loaded.
- Open a file and note that LSP features are enabled.
Actual Behavior: Opening a file (not using the CLI) does not load the primary LSP for the language (TypeScript or Go) as soon as the workspace loads. Expected Behavior: Opening a file (not using the CLI) correctly loads the primary LSP for the language (TypeScript or Go) as soon as the workspace loads.
Zed Version and System Specs
Zed: v0.174.6 (Zed) OS: macOS 15.3.1 Memory: 16 GiB Architecture: aarch64
Hey, thanks for reporting this. This is likely an issue with environment variables and paths.
How were the LSP's installed? Were they installed through Zed or did you install them yourself some other way? If you installed them yourself, how?
Additionally, could you please provide any error messages you are seeing when the LSPs fail to start, either in the UI, error notification (bottom left near diagnostics count icon), or in your zed log (zed: open log)
Once we're able to understand what is going wrong here we'll try and get it fixed for you as soon as possible!
Thanks @probably-neb!
LSP's were installed with Zed automatically. I'm not seeing any error messages unfortunately, but I've grabbed the logs: https://gist.github.com/zacowan/1fb943a92c06b71748dbb93b8444d715.
At a quick glance, environment variables look like they might be the culprit. I've had a read through of the docs and stumbled upon this: https://zed.dev/docs/environment?highlight=environment%20variables#launched-via-window-manager-dock-or-launcher, which does seem to illustrate what might be the problem here.
The languages I tested were Go and TypeScript - for these, I set environments variables like so (fnm is a tool for managing different versions of node.js):
eval "$(fnm env --use-on-cd)"
export GOPATH="some/path"
export PATH="$GOPATH/bin:$PATH"
Not sure if it's a me/config problem or an actual problem, lmk what you think 😁
Hmm, a couple things are weird here.
- we should absolutely be seeing errors in your logs if they're failing to start.
- we use our own bundled version of node to run the installed TypeScript LSP, both of which we (should) use absolute paths to access so env vars shouldn't mess with that
- we do depend on the user having go installed to run
go installto installgoplsfor them, but then we move the installed binary to our folder where we keep the rest of the LSP's and run it with an absolute path after that, so I also see no reason why that wouldn't be working either?
Based on all of that, env vars are probably not the issue. I've got a couple other things for you to try so I can hopefully figure out what's going wrong here
- After opening Zed not through the
cliin a go project, could you runwhich goin the Zed terminal and make suregois found on the path? - In both a go project and a ts project, opened not through the cli
- run
debug: open language server logs - in the pane that opens up, click on the thing that looks like the name of an LSP in the top left, and select the relevant language server (
goplsfor go andvtslsfor ts) - Look at the server logs to see if there's anything of note
- Click where it says "Server Logs" next to the LSP name and click through all of the options (server trace, rpc messages, etc) and look for anything noteworthy
- When you have RPC Messages selected, click around in the project, maybe type a little, a bunch of json messages should appear in the LSP logs pane, if nothing appears but the Server info, logs, and trace seem fine that's definitely an issue
- If you feel comfortable pasting the output from any of the LSP logs here, I'd be happy to take a look
- run
Thanks, and sorry for the delayed response. Hopefully we can get this figured out pretty fast for you!
no worries on the delay!
-
which godoes suggest go is available in the path (ran in the zed integrated terminal when NOT opened via CLI):
- For both my Go project and my TS project, I can open the logs but there's no logs for me to look at (no language servers available to select, NOT opened via CLI):
And to be clear, I can open and view logs when I open these projects from the CLI.
Not super helpful I realize - let me know if there's a workaround and I'm happy to retry 2 and/or get any logs sent over
Weird, so it seems like we are attempting to start the language servers, and hitting some error that we're not logging that causes them to fail to be registered at all. Maybe it is an env var issue?
Either way I'll look into this more and see if we can at least make sure all the cases where LSPs fail to launch & register get logged appropriately.
So, current plan, unless I come up with something better or figure out what's going wrong, is to make sure we have 100% LSP startup error logging coverage, release that, and see if the additional logs provide any useful information for this error you're having. This isn't my favorite solution, but it's all I've got at this point.
To that end, it seems like the error case logs you provided end kind of abruptly, would you mind opening not via the CLI, and clicking around coding for a minute or so and then share the complete log? I just want to make sure we're not missing a log that comes later.
Thanks, and hopefully we can get this fixed for you very soon
@probably-neb sorry for the delay! That sounds like a solid plan 😁
I did a fresh install of the latest version of Zed, opened my project, coded for a bit, and then attempted to restart the language server. The result of those logs is here: https://gist.github.com/zacowan/9aa1400ec56a74c97ab7f7072874da1a
Keep me in the loop if there's more that I can do! Looking forward to the fix
Maybe related:
- https://github.com/zed-industries/zed/issues/22575