golangci/golangci-lint · error
compile schema: %w
Error message
compile schema: %w
What it means
validateConfiguration builds a jsonschema compiler with the embedded loader (jsonsch.NewEmbedLoader) and Draft7, then compiles the bundled schema with compiler.Compile(schemaPath). Any failure to load/compile the schema itself is wrapped as "compile schema: %w" — this indicates a problem with the schema, not the user's config.
Source
Thrown at pkg/commands/config_verify.go:53
}
printValidationDetail(cmd, v.DetailedOutput())
return errors.New("the configuration contains invalid elements")
}
return nil
}
func validateConfiguration(schemaPath, targetFile string) error {
compiler := jsonschema.NewCompiler()
compiler.UseLoader(jsonsch.NewEmbedLoader())
compiler.DefaultDraft(jsonschema.Draft7)
// The name is not us
schema, err := compiler.Compile(schemaPath)
if err != nil {
return fmt.Errorf("compile schema: %w", err)
}
var m any
switch strings.ToLower(filepath.Ext(targetFile)) {
case ".yaml", ".yml", ".json":
m, err = decodeYamlFile(targetFile)
if err != nil {
return err
}
case ".toml":
m, err = decodeTomlFile(targetFile)
if err != nil {
return err
}
default:View on GitHub (pinned to ed7a235d2d)
Solutions
- Rebuild/reinstall the binary from a clean checkout so the go:embed'ed schema assets are present
- Check the wrapped %w error for the schema path/resource that failed to load
- Update to the latest release — schema compile failures are usually tool-internal and fixed upstream
- If patching, validate the embedded schema JSON is valid Draft7 and reachable at schemaPath
Example fix
// before (custom build with stripped embed) // go build -tags noembed ./... -> compile schema: open jsonschema/schema.json: file does not exist // after // keep embed directives intact and build normally go build ./cmd/golangci-lint
Defensive patterns
Strategy: fallback
Validate before calling
// preflight: ensure the embedded schema resource is present
if _, err := fs.ReadFile(embeddedFS, schemaPath); err != nil {
return fmt.Errorf("schema asset missing from build at %s: %w", schemaPath, err)
} Type guard
func isSchemaCompileError(err error) bool {
return err != nil && strings.Contains(err.Error(), "compile schema")
} Try / catch
schema, err := compiler.Compile(schemaPath)
if err != nil {
if isSchemaCompileError(err) {
return fmt.Errorf("tool build appears corrupted (schema won't compile): %w — reinstall the binary", err)
}
return fmt.Errorf("compile schema: %w", err)
} Prevention
- Build with standard tooling so go:embed assets are included; avoid stripped/custom tags
- Reinstall from an official release if schema compilation fails
- Keep the tool updated — schema changes ship with releases
- Never modify the embedded schema JSON without validating it as Draft7
When it happens
Trigger: compiler.Compile(schemaPath) fails because the embedded schema resource cannot be located, parsed, or is invalid Draft7 JSON Schema.
Common situations: Corrupted or stripped binary where embedded assets (go:embed) are missing; an internal bug after a schema upgrade; running a modified/patched build lacking the embedded jsonschema files.
Related errors
AI-assisted analysis of golangci/golangci-lint@ed7a235d2d (2026-09-02).
Data as JSON: /api/errors/4691900714acdc04.
Report an issue: GitHub.