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

问题描述 投票:0回答:1

在emacs中,使用gopls,但它不能在路径中找到 go 在我的道路上。但它在那里,我可以运行它。向社区求助,看看我是否遗漏了什么。我可以毫无问题地运行一个基本的金币服务器。

使用这个 配置,来自docs。

输出。

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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/internal/jsonrpc2/handler.go:110 +0x6c
created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1
    /Users/seanh/go/pkg/mod/golang.org/x/[email protected]/internal/jsonrpc2/handler.go:107 +0x187

Process gopls stderr finished
go emacs emacs-lsp
1个回答
2
投票

一个猜测:The PATH 在Emacs中,env var可能与你正在运行的其他shell不同。 你可以用 (getenv "PATH") 在Emacs中,你可以用

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

此外,如果你从同一个shell启动Emacs,可以发现 gopls,Emacs应该有同样的 PATH var,一切都应该正常。

至于 何以PATH这与你启动Emacs和shell的方式有关。

© www.soinside.com 2019 - 2024. All rights reserved.