flipped-aurora/gin-vue-admin · error

未检测到可用的 Go 环境,且本地没有可复用的 MCP 独立二进制

Error message

未检测到可用的 Go 环境,且本地没有可复用的 MCP 独立二进制

What it means

ensureManagedBinary guarantees a runnable MCP standalone binary: it first tries building with the local Go toolchain, and otherwise falls back to an existing prebuilt binary at binaryPath. This error is thrown when BOTH are unavailable — no `go` command on PATH AND no previously built binary exists — so the managed start has no way to produce a runnable MCP process.

Source

Thrown at server/mcp/standalone_manager.go:350

		cmd := exec.CommandContext(buildCtx, goBin, "build", "-o", binaryPath, "./cmd/mcp")
		cmd.Dir = serverRoot
		output, err := cmd.CombinedOutput()
		if err != nil {
			message := strings.TrimSpace(string(output))
			if message != "" {
				return "", fmt.Errorf("构建 MCP 独立服务失败: %w, 输出: %s", err, message)
			}
			return "", fmt.Errorf("构建 MCP 独立服务失败: %w", err)
		}
		return binaryPath, nil
	}

	if fileExists(binaryPath) {
		return binaryPath, nil
	}

	return "", errors.New("未检测到可用的 Go 环境,且本地没有可复用的 MCP 独立二进制")
}

func resolveMCPServerRoot() string {
	root := strings.TrimSpace(global.GVA_CONFIG.AutoCode.Root)
	serverDir := strings.TrimSpace(global.GVA_CONFIG.AutoCode.Server)
	if serverDir == "" {
		serverDir = "server"
	}

	candidates := []string{}
	if root != "" {
		candidates = append(candidates, filepath.Join(root, filepath.FromSlash(serverDir)))
		candidates = append(candidates, root)
	}

	if cwd, err := os.Getwd(); err == nil {
		candidates = append(candidates, cwd)
		candidates = append(candidates, filepath.Join(cwd, "server"))

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Install Go and ensure `go` is on PATH (go version should succeed for the backend process user)
  2. Build the MCP standalone binary once on a machine with Go and copy it to the expected runtime binaryPath
  3. Fix PATH in the backend service environment (systemd Environment= / Dockerfile ENV) so `go` is discoverable
  4. Re-check after cleaning the runtime dir: without Go the binary will never be rebuilt

Example fix

# before: no go toolchain
go version  # command not found
# after
# Debian/Ubuntu
apt-get install -y golang-go
# or use official tarball
wget https://go.dev/dl/go1.22.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.22.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
Defensive patterns

Strategy: validation

Validate before calling

if _, err := exec.LookPath("go"); err != nil {
    return errors.New("go toolchain required to build MCP standalone binary (or prebuild it into the runtime dir)")
}

Try / catch

if _, err := ensureManagedBinary(); err != nil {
    log.Fatalf("MCP binary unavailable: %v — install Go or ship a prebuilt binary", err)
}

Prevention

When it happens

Trigger: StartManagedStandalone on a machine where the Go toolchain is not installed or not on PATH, and the mcp runtime directory contains no previously compiled standalone binary.

Common situations: Deploying to a slim production image without Go; running the page in Docker where PATH lacks go; first-time start on a new machine; cleaned runtime directory removing the cached binary.

Related errors


AI-assisted analysis of flipped-aurora/gin-vue-admin@3136500ef3 (2026-08-31). Data as JSON: /api/errors/99fe56c5cbd94320. Report an issue: GitHub.