{"record":{"id":"53faeb17dbd98600","repo":"twpayne/chezmoi","slug":"s-not-found","errorCode":null,"errorMessage":"%s: not found","messagePattern":"(.+?): not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/chezmoi/sourcestate.go","lineNumber":3000,"sourceCode":"\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,\n\toptions *AddOptions,\n) (SourceStateEntry, error) {\n\tswitch actualStateEntry := actualStateEntry.(type) {\n\tcase *ActualStateAbsent:\n\t\treturn nil, fmt.Errorf(\"%s: not found\", destAbsPath)\n\tcase *ActualStateDir:\n\t\treturn s.newSourceStateDirEntry(actualStateEntry, fileInfo, parentSourceRelPath, targetRelPath, options), nil\n\tcase *ActualStateFile:\n\t\treturn s.newSourceStateFileEntryFromFile(actualStateEntry, fileInfo, parentSourceRelPath, options)\n\tcase *ActualStateSymlink:\n\t\treturn s.newSourceStateFileEntryFromSymlink(actualStateEntry, fileInfo, parentSourceRelPath, options)\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"%T: unsupported type\", actualStateEntry))\n\t}\n}\n\nfunc (e *External) IsExternal() bool {\n\treturn true\n}\n\nfunc (e *External) OriginString() string {\n\turlStr := cmp.Or(append([]string{e.URL}, e.URLs...)...)\n\treturn urlStr + \" defined in \" + e.sourceAbsPath.String()","sourceCodeStart":2982,"sourceCodeEnd":3018,"githubUrl":"https://github.com/twpayne/chezmoi/blob/f901167e4685db90da56d6a2a19df642cb3e0247/internal/chezmoi/sourcestate.go#L2982-L3018","documentation":"When translating a target's actual state into a source-state entry (during chezmoi add), an ActualStateAbsent means the destination path does not exist on the filesystem, so there is nothing to add and chezmoi errors '<path>: not found'.","triggerScenarios":"Running chezmoi add with a target path that does not exist in the destination (typo, deleted file, or path relative to the wrong base directory).","commonSituations":"Adding a file after deleting or renaming it; typo in path passed to `chezmoi add`; assuming ~-relative resolution differs from actual target path; adding something managed only by a script.","solutions":["Verify the path exists on the target system (ls the exact path chezmoi resolves)","Recreate the file/directory before running chezmoi add","Check spelling and that you are referencing the target path, not the source path"],"exampleFix":"// before\nchezmoi add ~/.zshrc   # file was deleted\n// after\ntouch ~/.zshrc  # or restore it, then\nchezmoi add ~/.zshrc","handlingStrategy":"validation","validationCode":"// check the target exists before `chezmoi add`\npath := os.ExpandEnv(\"$HOME/.zshrc\")\nif _, err := os.Lstat(path); err != nil {\n  return fmt.Errorf(\"cannot add %s: %w\", path, err)\n}","typeGuard":"func targetExists(absPath string) bool {\n  _, err := os.Lstat(absPath)\n  return err == nil\n}","tryCatchPattern":"if err := runAdd(targets); err != nil {\n  if strings.Contains(err.Error(), \": not found\") {\n    return fmt.Errorf(\"target missing on filesystem; create it or fix the path: %w\", err)\n  }\n  return err\n}","preventionTips":["Verify the exact target path exists before running chezmoi add","Watch for renames/deletes between generating the file and adding it","Remember chezmoi add takes target paths (~/.foo), not source paths"],"tags":["chezmoi","add","filesystem"],"backgroundTag":"file-not-found","analyzedSha":"f901167e4685db90da56d6a2a19df642cb3e0247","analyzedAt":"2026-09-01T18:16:41.508Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}