golangci/golangci-lint · error

clone golangci-lint: %w

Error message

clone golangci-lint: %w

What it means

Builder.Build (used by `golangci-lint custom`) starts by cloning the golangci-lint repository at the configured version into a temp directory. A clone failure is wrapped as "clone golangci-lint: %w" — typically a git/network/clone-target problem, before any plugin or build steps run.

Source

Thrown at pkg/commands/internal/builder.go:48

}

// NewBuilder creates a new Builder.
func NewBuilder(logger logutils.Log, cfg *Configuration, root string) *Builder {
	return &Builder{
		cfg:  cfg,
		log:  logger,
		root: root,
		repo: filepath.Join(root, "golangci-lint"),
	}
}

// Build builds the custom binary.
func (b Builder) Build(ctx context.Context) error {
	b.log.Infof("Cloning golangci-lint repository")

	err := b.clone(ctx)
	if err != nil {
		return fmt.Errorf("clone golangci-lint: %w", err)
	}

	b.log.Infof("Adding plugin imports")

	err = b.updatePluginsFile()
	if err != nil {
		return fmt.Errorf("update plugin file: %w", err)
	}

	b.log.Infof("Adding replace directives")

	err = b.addToGoMod(ctx)
	if err != nil {
		return fmt.Errorf("add to go.mod: %w", err)
	}

	b.log.Infof("Running go mod tidy")

View on GitHub (pinned to ed7a235d2d)

Solutions

  1. Read the wrapped cause for the underlying git error (auth, DNS, tag not found).
  2. Verify the version exists: git ls-remote --tags https://github.com/golangci/golangci-lint.
  3. Ensure git is installed and network/proxy (HTTP(S)_PROXY) allows github.com access.
  4. If behind a proxy, configure go env GOPROXY and git insteadOf/credentials appropriately.

Example fix

// before (.custom-gcl.yml)
version: master-unknown
// after
version: v1.61.0  # existing tag
// plus ensure git present: which git
Defensive patterns

Strategy: validation

Validate before calling

if _, err := exec.LookPath("git"); err != nil { return fmt.Errorf("git not installed") }
// network + tag check before building the custom binary
if err := exec.Command("git", "ls-remote", "--exit-code",
  "https://github.com/golangci/golangci-lint", "refs/tags/"+version).Run(); err != nil {
  return fmt.Errorf("cannot reach repo or tag %s missing", version)
}

Try / catch

if err := customCmd.Run(); err != nil {
  if strings.Contains(err.Error(), "clone golangci-lint") {
    log.Fatalf("clone failed, check git/network/version: %v", errors.Unwrap(err))
  }
  return err
}

Prevention

When it happens

Trigger: Running `golangci-lint custom` when b.clone(ctx) fails: invalid or nonexistent version tag, unreachable github.com, missing git binary, proxy/firewall blocking, or shallow-clone/SSH auth issues.

Common situations: Specifying a version that doesn't exist in .custom-gcl.yml; corporate proxy or offline environment; git not installed in CI image; SSH-only git config when HTTPS is required.

Related errors


AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02). Data as JSON: /api/errors/45c2716ae1db258b. Report an issue: GitHub.