templ: VScode extension lsp error
I’m getting the following error on the extension start up
[Error - 9:45:21 PM] Stopping server failed
Error: Client is not running and can't be stopped. It's current state is: starting
at LanguageClient.shutdown (/home/andrii/.vscode/extensions/a-h.templ-0.0.14/node_modules/vscode-languageclient/lib/common/client.js:914:1)
at LanguageClient.stop (/home/andrii/.vscode/extensions/a-h.templ-0.0.14/node_modules/vscode-languageclient/lib/common/client.js:885:1)
at LanguageClient.stop (/home/andrii/.vscode/extensions/a-h.templ-0.0.14/node_modules/vscode-languageclient/lib/node/main.js:150:1)
at LanguageClient.handleConnectionError (/home/andrii/.vscode/extensions/a-h.templ-0.0.14/node_modules/vscode-languageclient/lib/common/client.js:1146:1)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
[Error - 9:45:21 PM] Server initialization failed.
Message: write EPIPE
Code: -32099
[Error - 9:45:21 PM] templ client: couldn't create connection to server.
Message: write EPIPE
Code: -32099
[Error - 9:45:21 PM] Connection to server got closed. Server will not be restarted.
About this issue
- Original URL
- State: open
- Created 9 months ago
- Comments: 23 (8 by maintainers)
Thanks @kingjulienboss - @alexpower2002 / @WanderningMaster - is that the same issue for you?
The troubleshooting steps are:
Check that go, gopls and templ are installed and are present in the path.
You should see 3 lines returned, showing the location of each binary:
Enable LSP logging
Use the “Preferences: Open User Settings (JSON)” command in VS Code and enable logging in templ.
Start up the project and include the logs
Bear in mind that your code will be included in the logs. Try to make a minimal reproduction if possible.
I’ve updated the probing to include checks for
gopls.exe
as well asgopls
in https://github.com/a-h/templ/commit/b6f0b3dad93a476f82657cf778ce7f7cef618752I had same problems with the plugin for Goland. I Fixed it with the following steps:
go
is installed globally (not only in Goland IDE)go install
installs the binaries to. (for me it was /User/{username}/go/bin)gopls
is also manually installedmaybe it would be nice to have a error message that gopls needs to be installed when starting the lsp server, otherwise it just exits without any message
I am having a related issue on arch:
https://berms.onlyfans.je/cb0c7ff4-7cfa-4f71-ac09-630b41f7bf13.png
@a-h I would also add the part of adding to bin path to the profile. In my case gopls and templ was working inside the terminal but not inside the extension. Might be because vscode uses some some other user to run the extensions to isolate it from other folders.
Hi folks, just to help with the mental model of how the VS Code LSP works…
The main task that the extension does is to run the
templ lsp
command.When the VS Code extension runs, it shows an information message to tell you what it’s going to execute at the command line, see https://github.com/a-h/templ-vscode/blob/aa9495fc6d1b0d132b19e8c5b1e6e362b94aa39d/src/main.ts#L67
If you can’t run this command line yourself, then that’s the main thing to fix. So…
templ
command at the command line:templ
binary is on your path.chmod +x /path/to/templ
.I’ll add these additional troubleshooting steps to the docs.
@laneherby you can check if the path /home/herby/go/bin is included in $PATH. You can check using
echo $PATH
.Thank you all guys @a-h @kingjulienboss, at least for me copying
gopls
binary to/usr/bin
did the trick