{"record":{"id":"a9105ce68d053a02","repo":"golangci/golangci-lint","slug":"file-s-not-found-w-a9105c","errorCode":null,"errorMessage":"file %s not found: %w","messagePattern":"file (.+?) not found: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/commands/internal/imports.go","lineNumber":27,"sourceCode":"\t\"text/template\"\n)\n\nconst importsTemplate = `\npackage main\n\nimport (\n{{range .Imports -}}\n\t_ \"{{.}}\"\n{{end -}}\n)\n`\n\nfunc (b Builder) updatePluginsFile() error {\n\timportsDest := filepath.Join(b.repo, \"cmd\", \"golangci-lint\", \"plugins.go\")\n\n\tinfo, err := os.Stat(importsDest)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"file %s not found: %w\", importsDest, err)\n\t}\n\n\tsource, err := generateImports(b.cfg)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"generate imports: %w\", err)\n\t}\n\n\tb.log.Infof(\"generated imports info %s:\\n%s\\n\", importsDest, source)\n\n\terr = os.WriteFile(filepath.Clean(importsDest), source, info.Mode())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"write file %s: %w\", importsDest, err)\n\t}\n\n\treturn nil\n}\n\nfunc generateImports(cfg *Configuration) ([]byte, error) {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/commands/internal/imports.go#L9-L45","documentation":"updatePluginsFile (part of the custom-build/plugin pipeline) expects cmd/golangci-lint/plugins.go to already exist inside the target repo. os.Stat fails, so the error wraps the underlying stat error (e.g. no such file or directory) with the path. The build aborts before imports are regenerated.","triggerScenarios":"Running Build (Builder.updatePluginsFile) against a repo checkout where cmd/golangci-lint/plugins.go is missing: fresh/partial clone, wrong b.repo path, or the file was deleted or gitignored.","commonSituations":"Building a customized golangci-lint with plugins from a sparse or tarball checkout; wrong repo root passed to Builder; plugins.go excluded by .gitignore or sparse-checkout.","solutions":["Ensure cmd/golangci-lint/plugins.go exists (restore from git or create a stub)","Correct the b.repo path passed to Builder so it points at the actual repo root","Use a full git clone, not a partial archive","Check .gitignore/sparse-checkout rules that may exclude plugins.go"],"exampleFix":"// before\nb := Builder{repo: \"/tmp/build\"} // no cmd/golangci-lint/plugins.go here\n// after\nb := Builder{repo: \"/go/src/github.com/golangci/golangci-lint\"} // repo containing cmd/golangci-lint/plugins.go","handlingStrategy":"validation","validationCode":"pluginsPath := filepath.Join(repo, \"cmd\", \"golangci-lint\", \"plugins.go\")\nif _, err := os.Stat(pluginsPath); os.IsNotExist(err) {\n\tos.MkdirAll(filepath.Dir(pluginsPath), 0o755)\n\tos.WriteFile(pluginsPath, []byte(\"package main\\n\"), 0o644)\n}","typeGuard":null,"tryCatchPattern":"err := builder.Build(ctx)\nif err != nil && strings.Contains(err.Error(), \"file \"+pluginsPath+\" not found\") {\n\t// restore the stub file, then retry the build\n}","preventionTips":["Keep a committed stub cmd/golangci-lint/plugins.go in custom-build repos","Use a full git clone rather than partial tarballs","Verify the repo root path before building","Do not gitignore plugins.go"],"tags":["go","build","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}