gpt4 book ai didi

go - 为什么emacs-lsp go-mode在路径中找不到go可执行文件?

转载 作者:行者123 更新时间:2023-12-01 22:06:36 25 4
gpt4 key购买 nike

在emacs中,使用gopls但在我的路径上找不到go。但它在那里,我可以运行它。向社区伸出援手,看看我是否缺少任何东西。我可以毫无问题地运行基本的gin服务器。

使用文档中的config

输出:

panic: err: exec: "go": executable file not found in $PATH: stderr: 

goroutine 73 [running]:
golang.org/x/tools/internal/lsp/debug.PrintVersionInfo.func2()
/Users/seanh/go/pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/lsp/debug/info.go:58 +0x1c3
golang.org/x/tools/internal/lsp/debug.section(0x1a2d520, 0xc00013de60, 0x0, 0x18cda9a, 0x7, 0xc0003bb588)
/Users/seanh/go/pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/lsp/debug/info.go:69 +0x319
golang.org/x/tools/internal/lsp/debug.PrintVersionInfo(0x1a40560, 0xc000226c60, 0x1a2d520, 0xc00013de60, 0x1, 0x0)
/Users/seanh/go/pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/lsp/debug/info.go:52 +0x1a7
golang.org/x/tools/internal/lsp.(*Server).initialized(0xc000230080, 0x1a40560, 0xc000226c60, 0x1fa2ef0, 0x0, 0x0)
/Users/seanh/go/pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/lsp/general.go:163 +0x1a3
golang.org/x/tools/internal/lsp.(*Server).Initialized(0xc000230080, 0x1a40560, 0xc000226c60, 0x1fa2ef0, 0x1fa2ef0, 0x0)
/Users/seanh/go/pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/lsp/server_gen.go:112 +0x49
golang.org/x/tools/internal/lsp/protocol.ServerHandler.func1(0x1a40560, 0xc000226c60, 0xc00022cd80, 0x1c650b5, 0x1f77a40)
/Users/seanh/go/pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/lsp/protocol/tsserver.go:97 +0x757
golang.org/x/tools/internal/lsp/lsprpc.handshaker.func1(0x1a40560, 0xc000226c60, 0xc00022cd80, 0x0, 0x0)
/Users/seanh/go/pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/lsp/lsprpc/lsprpc.go:531 +0x505
golang.org/x/tools/internal/jsonrpc2.MustReply.func1(0x1a40560, 0xc000226c60, 0xc00022cd80, 0x1007aaf, 0xc0002901d8)
/Users/seanh/go/pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/jsonrpc2/handler.go:54 +0x47
golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2(0xc00009eb40, 0xc000226de0, 0xc000232130, 0x1a40560, 0xc000226c60, 0xc00022cd80)
/Users/seanh/go/pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/jsonrpc2/handler.go:110 +0x6c
created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1
/Users/seanh/go/pkg/mod/golang.org/x/tools@v0.0.0-20200407041343-bf15fae40dea/internal/jsonrpc2/handler.go:107 +0x187

Process gopls stderr finished

最佳答案

一个猜测:与您正在运行的任何其他Shell相比,Emacs中的PATH env var可能有所不同。您可以在Emacs中使用(getenv "PATH")进行检查,也可以使用

(setenv "PATH" (concat (getenv "PATH") ":/path/to/go"))

同样,如果您从可以找到 gopls的同一 shell 启动Emacs,则Emacs应该具有相同的 PATH var,并且一切正常。

至于 PATH与众不同的原因,这与您启动Emacs和shell的方式有关。

关于go - 为什么emacs-lsp go-mode在路径中找不到go可执行文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61427165/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com