flipped-aurora/gin-vue-admin · error

GVA_MCP_BIN 指向的文件不存在: %s

Error message

GVA_MCP_BIN 指向的文件不存在: %s

What it means

resolveManagedStartCommand validates the GVA_MCP_BIN environment variable and fails fast when it points to a path that does not exist on disk. This is a configuration error: the user explicitly told the manager which binary to run, but the path is wrong.

Source

Thrown at server/mcp/standalone_manager.go:306

			}
		}
	}
}

func resolveManagedStartCommand() (string, []string, string, string, error) {
	serverRoot := resolveMCPServerRoot()
	if serverRoot == "" {
		return "", nil, "", "", errors.New("未找到 server 根目录,无法启动 MCP 独立服务")
	}

	configPath, err := resolveMCPConfigPath(serverRoot)
	if err != nil {
		return "", nil, "", "", err
	}

	if explicit := strings.TrimSpace(os.Getenv("GVA_MCP_BIN")); explicit != "" {
		if !fileExists(explicit) {
			return "", nil, "", "", fmt.Errorf("GVA_MCP_BIN 指向的文件不存在: %s", explicit)
		}
		return explicit, []string{"-config", configPath}, filepath.Dir(explicit), configPath, nil
	}

	binaryPath, err := ensureManagedBinary(serverRoot)
	if err != nil {
		return "", nil, "", "", err
	}

	return binaryPath, []string{"-config", configPath}, serverRoot, configPath, nil
}

func ensureManagedBinary(serverRoot string) (string, error) {
	runtimeDir, err := ensureMCPRuntimeDir()
	if err != nil {
		return "", err
	}

View on GitHub (pinned to 3136500ef3)

Solutions

  1. Set GVA_MCP_BIN to a verified absolute path of the compiled binary: ls -la "$GVA_MCP_BIN" to confirm.
  2. Unset GVA_MCP_BIN so the manager falls back to ensureManagedBinary, which locates/builds ./cmd/mcp automatically.
  3. If using ~ in the path, expand it ($HOME or an absolute path) — Go does not expand tilde in env vars.
  4. Rebuild and reinstall the binary at the expected path for the current platform.

Example fix

// before
export GVA_MCP_BIN="~/bin/gva-mcp"          # tilde not expanded; file may not exist
// after
export GVA_MCP_BIN="$HOME/bin/gva-mcp"      # absolute path
ls -la "$GVA_MCP_BIN" || go build -o "$HOME/bin/gva-mcp" ./cmd/mcp
Defensive patterns

Strategy: validation

Validate before calling

bin := os.Getenv("GVA_MCP_BIN")
if bin != "" {
    if _, err := os.Stat(bin); err != nil {
        return fmt.Errorf("GVA_MCP_BIN points to missing file: %s", bin)
    }
}

Try / catch

status, err := StartManagedStandalone(ctx)
if err != nil && strings.Contains(err.Error(), "GVA_MCP_BIN") {
    os.Unsetenv("GVA_MCP_BIN") // fall back to auto-locate/auto-build
    status, err = StartManagedStandalone(ctx)
}

Prevention

When it happens

Trigger: GVA_MCP_BIN is set (non-empty after TrimSpace) and fileExists(explicit) returns false: typo in path, file deleted after a clean, relative path evaluated from an unexpected working directory, binary rebuilt under a different name.

Common situations: CI/CD moved or renamed the artifact; developer pointed GVA_MCP_BIN at a source file instead of a compiled binary; path uses ~ which is not shell-expanded for os.Getenv; container image changed.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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