cursor 使用 gvm管理的go的环境出现 Failed to find the “go“ binary in either GOROOT() 错误

一、测试环境
  1. windows11 cursor 2.1.20版本 连接 wsl2 Ubuntu22.04,gvm 安装在linux子系统
  2. 同样的环境 vscode 正常使用gvm的go环境路径,而cursor报下面的错误

错误如下

bash 复制代码
Failed to find the "go" binary in either GOROOT() or PATH(/home/shayuer/.cursor-server/bin/a8d8905b06c8da1739af6f789efd59c28ac2a680/bin/remote-cli:/home/shayuer/.local/bin:/usr/local/cuda-12.9/bin:/run/user/1000/fnm_multishells/2918_1763875263165/bin:/home/shayuer/.local/share/fnm:/home/shayuer/miniconda3/bin:/home/shayuer/miniconda3/condabin:/home/shayuer/.cursor-server/bin/a8d8905b06c8da1739af6f789efd59c28ac2a680/bin/remote-cli:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program Files/Volta:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0:/mnt/c/WINDOWS/System32/OpenSSH:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA App/NvDLISR:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/Program Files/dotnet:/mnt/d/Programs/Git/cmd:/mnt/c/Users/amliu/AppData/Local/Volta/bin:/mnt/c/Users/amliu/.loca...

查询相关资料有说是 cursor 连接wsl2环境在开启时不会像vscode一样加载登录 .bashrcgvm 没有更改GOPATH,而全局变量中没有安装go,于是报错了

二、cursor 在 settings.json 配置 GO环境变量(更换新的go版本需要重新指定)

秉着继续使用gvm管理多个go版本,在使用cursor开发go程序时,可以使用手动在settings.json 文件中加入go的路径,后续如果使用其他go版本,在gvm install 需要的go版本后再次将cursorsettings.json文件 go路径重新指定新的即可,步骤如下:

  1. cursor 主页面下使用快捷键:ctrl + shift + p,输入 Preferences: Open User Settings (JSON) 打开 settings.json 配置文件
  2. 写入以下go配置(去掉注释,替换成自己的实际路径):
bash 复制代码
	"go.alternateTools": {
        "go": "/home/shayuer/.gvm/gos/go1.22.12/bin/go"  // 指定 go 可执行文件,使用gvm管理的路径
    },
    "go.goroot": "/home/shayuer/.gvm/gos/go1.22.12",      // 使用gvm管理的路径
    "go.gopath": "/home/shayuer/.gvm/pkgsets/go1.22.12/global"   //设置项目的 GOPATH,使用gvm管理的路径
  1. 重启 cursor,新安装的go环境IDE还会安装 gopls,需要等待一段时间,终端中会打印出gopls安装的路径,观察是否与设置的路径相同

相关路径为:

bash 复制代码
toolsGopath: 
gopath: /home/shayuer/.gvm/pkgsets/go1.22.12/global
GOROOT: /home/shayuer/.gvm/gos/go1.22.12
PATH: /home/shayuer/.gvm/gos/go1.22.12/bin:/home/shayuer/.cursor-server/bin/a8d8905b06c8da1739af6f789efd59c28ac2a680/bin/remote-cli:/home/shayuer/.local/bin:/usr/local/cuda-12.9/bin .....
三、ubuntu 使用 gvm 安装管理多个go版本

ubuntu22.04安装gvm管理go

相关推荐
张忠琳3 小时前
【Go 1.26.4】(Part 1) Go 1.26.4 超深度源码分析 — 总体架构与模块全景
开发语言·golang
协享科技7 小时前
Spring Boot 与 Go 双服务架构实践:从单体拆分到通信设计
java·人工智能·spring boot·后端·架构·golang·ai编程
小时前端10 小时前
AI 辅助编程真的用对了么? agents, commands, memory, rules, skills 都是干什么的
ai编程·cursor
周杰伦的稻香10 小时前
Go + Redis:本地部署高性能图片主色调提取服务
开发语言·redis·golang
福大大架构师每日一题10 小时前
2026年6月TIOBE编程语言排行榜,Go语言排名第13,Rust语言排名12。关于Rust已进入平台期的报道似乎为时过早。
开发语言·golang·rust
猫头_11 小时前
跨 AI IDE 的协作痛点:用了五六个 AI 编辑器,提示词(Skills)该怎么统一管理?
openai·ai编程·cursor
小时前端13 小时前
如何实现AI驱动开发代码采纳率达到100%?
ai编程·领域驱动设计·cursor
伊灵eLing14 小时前
GoLang 语言基础
开发语言·后端·golang
踏着七彩祥云的小丑14 小时前
Go学习第4天:条件、循环语句+函数
学习·golang·go
小小龙学IT16 小时前
Go 后端开发中的并发模式:从 Goroutine 到 Pipeline 实战
开发语言·后端·golang