golang/go · error

relative pattern not allowed in GOVCS: %q

Error message

relative pattern not allowed in GOVCS: %q

What it means

GOVCS patterns must be module path prefixes (e.g., 'github.com', 'public'), not filesystem-relative paths. If search.IsRelativePath(pattern) is true (pattern starts with ./, ../, or similar), the entry is rejected.

Source

Thrown at src/cmd/go/internal/vcs/vcs.go:652

	have := make(map[string]string)
	for item := range strings.SplitSeq(s, ",") {
		item = strings.TrimSpace(item)
		if item == "" {
			return nil, fmt.Errorf("empty entry in GOVCS")
		}
		pattern, list, found := strings.Cut(item, ":")
		if !found {
			return nil, fmt.Errorf("malformed entry in GOVCS (missing colon): %q", item)
		}
		pattern, list = strings.TrimSpace(pattern), strings.TrimSpace(list)
		if pattern == "" {
			return nil, fmt.Errorf("empty pattern in GOVCS: %q", item)
		}
		if list == "" {
			return nil, fmt.Errorf("empty VCS list in GOVCS: %q", item)
		}
		if search.IsRelativePath(pattern) {
			return nil, fmt.Errorf("relative pattern not allowed in GOVCS: %q", pattern)
		}
		if old := have[pattern]; old != "" {
			return nil, fmt.Errorf("unreachable pattern in GOVCS: %q after %q", item, old)
		}
		have[pattern] = item
		allowed := strings.Split(list, "|")
		for i, a := range allowed {
			a = strings.TrimSpace(a)
			if a == "" {
				return nil, fmt.Errorf("empty VCS name in GOVCS: %q", item)
			}
			allowed[i] = a
		}
		cfg = append(cfg, govcsRule{pattern, allowed})
	}
	return cfg, nil
}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Use module path patterns, not filesystem paths — GOVCS matches against import paths, not directories
  2. For a module hosted at example.com/myproj, use `GOVCS=example.com:git`
  3. Use the built-in 'public' and 'private' pattern keywords for broad rules

Example fix

# before: relative filesystem path (wrong)
export GOVCS="./myproject:git"

# after: module import path pattern
export GOVCS="example.com:git"
Defensive patterns

Strategy: validation

Validate before calling

# Validate GOVCS patterns are not relative paths
GOVCS_VAL="${GOVCS:-}"
if [ -n "$GOVCS_VAL" ]; then
  echo "$GOVCS_VAL" | tr ',' '\n' | while IFS= read -r entry; do
    entry="$(echo "$entry" | xargs)"
    pattern="$(echo "${entry%%:*}" | xargs)"
    case "$pattern" in
      ./*|../*|.\\*|..\\*) echo "ERROR: relative pattern not allowed in GOVCS: $pattern" ;;
    esac
  done
fi

Prevention

When it happens

Trigger: A GOVCS entry uses a relative filesystem path as a pattern: `GOVCS=./local:git` or `GOVCS=../shared:fossil`.

Common situations: Confusing GOVCS import-path patterns with filesystem paths; assuming GOVCS matches local directory paths.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/6f09b8417ac8329a. Report an issue: GitHub.