{"record":{"id":"389f9279494d8afa","repo":"twpayne/chezmoi","slug":"s-q-w","errorCode":null,"errorMessage":"%s: %q: %w","messagePattern":"(.+?): %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/chezmoi/sourcestate.go","lineNumber":2977,"sourceCode":"\t\t\t}\n\t\t}\n\t}\n\tif err := concurrentWalkSourceDir(ctx, s.system, scriptsDirAbsPath, walkFunc); err != nil {\n\t\treturn nil, err\n\t}\n\treturn allSourceStateEntries, nil\n}\n\n// readVersionFile reads a .chezmoiversion file from sourceAbsPath and returns\n// an error if the version is newer that s's version.\nfunc (s *SourceState) readVersionFile(sourceAbsPath AbsPath) error {\n\tdata, err := s.system.ReadFile(sourceAbsPath)\n\tif err != nil {\n\t\treturn err\n\t}\n\tversion, err := semver.NewVersion(strings.TrimSpace(string(data)))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"%s: %q: %w\", sourceAbsPath, data, err)\n\t}\n\tvar zeroVersion semver.Version\n\tif s.version != zeroVersion && s.version.LessThan(*version) {\n\t\treturn &TooOldError{\n\t\t\tHave: s.version,\n\t\t\tNeed: *version,\n\t\t}\n\t}\n\treturn nil\n}\n\n// sourceStateEntry returns a new SourceStateEntry based on actualStateEntry.\nfunc (s *SourceState) sourceStateEntry(\n\tactualStateEntry ActualStateEntry,\n\tdestAbsPath AbsPath,\n\tfileInfo fs.FileInfo,\n\tparentSourceRelPath SourceRelPath,\n\ttargetRelPath RelPath,","sourceCodeStart":2959,"sourceCodeEnd":2995,"githubUrl":"https://github.com/twpayne/chezmoi/blob/f901167e4685db90da56d6a2a19df642cb3e0247/internal/chezmoi/sourcestate.go#L2959-L2995","documentation":"This wrapped error originates in chezmoi's source state handling (around sourcestate.go:2977, in the script-related error paths) and follows the format '%s: %q: %w': the first %s is the context (usually the target path of the source entry), %q quotes the specific item — commonly a script name or attribute being processed — and %w embeds the underlying error, preserving it for errors.Is/As unwrapping. It is raised when an operation on a source-state entry (such as reading, hashing, or evaluating a script) fails due to an underlying I/O, permission, or parse error. Diagnose it by reading the wrapped error at the end of the message: for example, a 'no such file or directory' means the referenced file is missing from the source state, while a permission error means chezmoi cannot read the entry. Fix the underlying condition (restore the missing file, correct permissions, or repair malformed frontmatter) in ~/.local/share/chezmoi.","triggerScenarios":"A source-state file (e.g. a .chezmoiversion-style file read here) whose trimmed contents fail semver parsing — empty file, plain text, 'v' prefix issues, or multiple lines/whitespace oddities that TrimSpace doesn't fix.","commonSituations":"Hand-edited version files containing notes or '>=1.2.3' constraints instead of a bare semver string; empty file committed by accident; version written as '1.2' (missing patch) which is not valid strict semver.","solutions":["Make the file contain exactly one valid semantic version string (e.g. 2.1.0), trimmed of extra text","Remove surrounding prose/quotes/constraint operators; use a bare MAJOR.MINOR.PATCH","Include the patch segment — '1.2' is invalid, '1.2.0' is valid"],"exampleFix":"// before (version file contents)\n1.2\n// after\n2.1.0","handlingStrategy":"validation","validationCode":"// validate the version file is strict semver before relying on it\nre := regexp.MustCompile(`^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z.-]+)?(\\+[0-9A-Za-z.-]+)?$`)\ndata, _ := os.ReadFile(versionFile)\nv := strings.TrimSpace(string(data))\nif !re.MatchString(v) { return fmt.Errorf(\"%s: not strict semver: %q\", versionFile, v) }","typeGuard":"func isStrictSemver(s string) bool {\n  _, err := semver.NewVersion(strings.TrimSpace(s))\n  return err == nil\n}","tryCatchPattern":"// catch and surface the offending contents\nversion, err := semver.NewVersion(strings.TrimSpace(string(data)))\nif err != nil {\n  return fmt.Errorf(\"version file %s contains invalid semver %q: %w\", path, data, err)\n}","preventionTips":["Keep version files to exactly one bare MAJOR.MINOR.PATCH line","Never hand-edit version files to include constraints or prose","Add CI validation that semver.NewVersion parses every version file"],"tags":["chezmoi","semver","parsing"],"backgroundTag":"invalid-semver","analyzedSha":"f901167e4685db90da56d6a2a19df642cb3e0247","analyzedAt":"2026-09-01T18:16:41.508Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}