Closed MukundSinghRajput closed 1 week ago
Something similar here on launch vscode. The error is coming from templ-vscode extension.
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x87a6c0]
goroutine 33 [running]:
github.com/a-h/templ/cmd/templ/lspcmd/proxy.(*Server).CodeAction(0xc00012c050, {0xa55250, 0xc0002ded70}, 0xc00020e0c0)
/home/nat/go/pkg/mod/github.com/a-h/templ@v0.2.707/cmd/templ/lspcmd/proxy/server.go:294 +0x480
github.com/a-h/protocol.serverDispatch({0xa55250, 0xc0002ded70}, {0xa5b300, 0xc00012c050}, 0xc0004c4060, {0xa55528, 0xc0004e2dc0})
/home/nat/go/pkg/mod/github.com/a-h/protocol@v0.0.0-20230224160810-b4eec67c1c22/server.go:158 +0x4013
github.com/a-h/protocol.NewServer.ServerHandler.func1({0xa55250, 0xc0002ded70}, 0xc0004c4060, {0xa55528, 0xc0004e2dc0})
/home/nat/go/pkg/mod/github.com/a-h/protocol@v0.0.0-20230224160810-b4eec67c1c22/server.go:36 +0x7e
github.com/a-h/protocol.Handlers.ReplyHandler.func1({0xa55250, 0xc0002ded70}, 0xc00011aa68, {0xa55528, 0xc0004e2dc0})
/home/nat/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/handler.go:35 +0xc6
github.com/a-h/protocol.Handlers.AsyncHandler.func2.2()
/home/nat/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/handler.go:114 +0x76
created by github.com/a-h/protocol.Handlers.AsyncHandler.func2 in goroutine 22
/home/nat/go/pkg/mod/go.lsp.dev/jsonrpc2@v0.10.0/handler.go:112 +0x165
[Error - 09:31:03] Server process exited with code 2.
[Error - 09:31:03] Connection to server got closed. Server will not be restarted.
@bbaulenas - the log you posted show that you're running templ v0.2.707, not v0.2.747. The issue was fixed in https://github.com/a-h/templ/releases/tag/v0.2.731
I'm sorry. That was my error.
My go package github.com/a-h/templ/cmd/templ
was older than my package github.com/a-h/templ
in the project.
Thank you!
@MukundSinghRajput - most of the time, when people report this, it's that they've installed templ on Windows, but are using WSL in VS Code, and haven't installed go
, gopls
and templ
in their WSL virtual machine.
Is that the case here?
@a-h No i am using Ubuntu and all the tools are installed :(
I have a Ubuntu laptop, and it's working OK for me. I added a new feature this morning to help debug issues like this.
If you run this:
go install github.com/a-h/templ/cmd/templ@main
templ info
It should print out a few log lines. It checks the path for various things that templ needs. What do you get?
mukund@mukund:~$ templ info
usage: templ <command> [<args>...]
templ - build HTML UIs with Go
See docs at https://templ.guide
commands:
generate Generates Go code from templ files
fmt Formats templ files
lsp Starts a language server for templ files
version Prints the version
@a-h I am getting this on using templ info
In that case, either you forgot to run go install github.com/a-h/templ/cmd/templ@main
first, the version of templ that's first in the path is an earlier version, or go install
has used a cached version.
The install might be cached, so if you run go install github.com/a-h/templ/cmd/templ@a98204d0eda8c14c468ff90549733064d232c7b5
instead, it should install the specific commit that contains the templ info
feature, and therefore print out the log lines.
(✓) os [ goos=linux goarch=amd64 ] (✓) go [ location=/usr/local/go/bin/go version=go version go1.22.5 linux/amd64 ] (✗) gopls [ location=/home/mukund/.local/bin version= message=failed to get gopls version: fork/exec /home/mukund/.local/bin: permission denied ] (✓) templ [ location=/usr/local/go/bin/templ version=v0.2.753 ] I built templ from source and getting this
Great!
It looks like templ can't run the gopls
executable at /home/mukund/.local/bin/gopls
. It's probably worth checking the ownership of the file, and that the file is marked as executable chmod +x /home/mukund/.local/bin/gopls
.
If you run /home/mukund/.local/bin/gopls --version
yourself, you should see the same problem that templ
is getting.
Thanks it is fixed now.
[Error - 6:54:19 PM] Client templ: connection to server is erroring. write EPIPE Shutting down server. [Error - 6:54:19 PM] Stopping server failed Error: Client is not running and can't be stopped. It's current state is: starting at CustomLanguageClient.shutdown (/home/mukund/.vscode/extensions/a-h.templ-0.0.26/dist/main.js:6934:19) at CustomLanguageClient.stop (/home/mukund/.vscode/extensions/a-h.templ-0.0.26/dist/main.js:6905:21) at CustomLanguageClient.stop (/home/mukund/.vscode/extensions/a-h.templ-0.0.26/dist/main.js:16101:22) at CustomLanguageClient.handleConnectionError (/home/mukund/.vscode/extensions/a-h.templ-0.0.26/dist/main.js:7166:18) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) [Error - 6:54:19 PM] Server initialization failed. Message: write EPIPE Code: -32099 [Error - 6:54:19 PM] templ client: couldn't create connection to server. Message: write EPIPE Code: -32099 [Error - 6:54:19 PM] Connection to server got closed. Server will not be restarted. [Error - 6:54:19 PM] Server process exited with code 1.
gopls
version : 0.16.x