flipped-aurora/gin-vue-admin · error
服务器未安装 Go 工具链,无法编译: %w
Error message
服务器未安装 Go 工具链,无法编译: %w
What it means
compileCliBinary shells out to the Go toolchain to cross-compile the CLI binary. Before doing anything it runs exec.LookPath("go"); when the `go` executable is not found in the server's PATH, this error is returned wrapping the underlying exec error. The service cannot build without a Go toolchain installed on the host.
Source
Thrown at server/plugin/ai/service/sys_cli_build.go:82
if err != nil {
return "", nil, err
}
manifest, err := buildSysCliManifest(cli, bindings)
if err != nil {
return "", nil, err
}
applyCliBuildBaseURL(&manifest, req.BaseURL)
manifestBytes, err := marshalSysCliManifest(manifest)
if err != nil {
return "", nil, err
}
return s.compileCliBinary(cli, manifestBytes, goos, goarch)
}
// compileCliBinary 把 manifest 内嵌进 gva 源码副本并交叉编译,返回二进制文件名与内容。
func (s *cliService) compileCliBinary(cli autoModel.SysCli, manifestBytes []byte, goos, goarch string) (string, []byte, error) {
if _, err := exec.LookPath("go"); err != nil {
return "", nil, fmt.Errorf("服务器未安装 Go 工具链,无法编译: %w", err)
}
absBuildRoot, err := filepath.Abs(cliBuildDir)
if err != nil {
return "", nil, fmt.Errorf("解析编译目录失败: %w", err)
}
if err := os.MkdirAll(absBuildRoot, 0o755); err != nil {
return "", nil, fmt.Errorf("创建编译根目录失败: %w", err)
}
buildDir, err := os.MkdirTemp(absBuildRoot, "cli-")
if err != nil {
return "", nil, fmt.Errorf("创建编译目录失败: %w", err)
}
defer os.RemoveAll(buildDir)
if err := copyCliSources(cliSourceDir, buildDir); err != nil {
return "", nil, err
}View on GitHub (pinned to 3136500ef3)
Solutions
- Install the Go toolchain on the server (e.g. download from go.dev/dl and extract to /usr/local/go)
- Add Go to the server process PATH, e.g. set PATH=/usr/local/go/bin:$PATH in the systemd unit or container env
- If using Docker, base the runtime image on golang:<ver> or install Go in the runtime stage
- Verify with `sudo -u <server-user> which go` that the exact service user can find go
- Precompile binaries offline and expose a download endpoint instead of compiling at runtime
Example fix
// before (dockerfile runtime stage) FROM alpine:3.19 // after FROM golang:1.22-alpine # or: RUN apk add --no-cache go && export PATH=$PATH:/usr/lib/go/bin
Defensive patterns
Strategy: validation
Validate before calling
if _, err := exec.LookPath("go"); err != nil {
return errors.New("Go toolchain required for CLI builds is not installed on the server")
} Try / catch
bin, content, err := svc.BuildCliBinary(cli, manifest, goos, goarch)
if err != nil {
if strings.Contains(err.Error(), "未安装 Go 工具链") {
return nil, errors.New("server missing Go toolchain; install Go or use prebuilt binaries")
}
return err
} Prevention
- Install Go in runtime container images, or pin a golang-based image
- Set PATH to include /usr/local/go/bin for the service user (check systemd unit / container env)
- Add a health/startup check that runs `go version` and surfaces a clear warning
- Consider precompiling offline and serving downloads instead of building at runtime
When it happens
Trigger: Invoking BuildCliBinary or BuildCliSkill on a server where the go binary is not installed, not in PATH for the server process user, or the service runs in a slim Docker image without the Go toolchain.
Common situations: Deploying in distroless/alpine runtime images that only contain the compiled binary; systemd services with a restricted PATH missing /usr/local/go/bin; container images built with multi-stage builds where Go was only in the builder stage; running under a user whose PATH differs from the shell's.
Related errors
- 构建 MCP 独立服务失败: %w
- 当前响应不支持流式输出
- 当前响应不支持流式输出
- 未找到 MCP 独立配置文件,请在当前目录、cmd/mcp 目录或通过 -config / GVA_MCP_CONFIG
- 未能自动识别项目根目录,请在 MCP 配置中设置 autocode.root
AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31).
Data as JSON: /api/errors/6eca38120daf5f40.
Report an issue: GitHub.