{"record":{"id":"954374de76c15ce6","repo":"twpayne/chezmoi","slug":"s-not-a-script","errorCode":null,"errorMessage":"%s: not a script","messagePattern":"(.+?): not a script","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/chezmoi/sourcestate.go","lineNumber":2941,"sourceCode":"\t\tswitch {\n\t\tcase err != nil:\n\t\t\treturn err\n\t\tcase strings.HasPrefix(fileInfo.Name(), Prefix):\n\t\t\treturn fmt.Errorf(\"%s: not allowed in %s directory\", sourceAbsPath, scriptsDirName)\n\t\tcase strings.HasPrefix(fileInfo.Name(), ignorePrefix):\n\t\t\tif fileInfo.IsDir() {\n\t\t\t\treturn fs.SkipDir\n\t\t\t}\n\t\t\treturn nil\n\t\tcase fileInfo.IsDir():\n\t\t\treturn nil\n\t\tcase fileInfo.Mode().IsRegular():\n\t\t\tfa, err := parseFileAttr(sourceName.String(), s.encryption.EncryptedSuffix())\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif fa.Type != SourceFileTypeScript {\n\t\t\t\treturn fmt.Errorf(\"%s: not a script\", sourceAbsPath)\n\t\t\t}\n\t\t\ttargetRelPath, err := parentSourceRelPath.Dir().TargetRelPath(s.encryption.EncryptedSuffix())\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\ttargetRelPath = targetRelPath.JoinString(fa.TargetName)\n\t\t\tif s.Ignore(targetRelPath) {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\tvar sourceStateEntry SourceStateEntry\n\t\t\ttargetRelPath, sourceStateEntry = s.newSourceStateFile(sourceAbsPath, sourceRelPath, fa, targetRelPath)\n\t\t\taddSourceStateEntry(targetRelPath, sourceStateEntry)\n\t\t\treturn nil\n\t\tdefault:\n\t\t\treturn &UnsupportedFileTypeError{\n\t\t\t\tabsPath: sourceAbsPath,\n\t\t\t\tmode:    fileInfo.Mode(),\n\t\t\t}","sourceCodeStart":2923,"sourceCodeEnd":2959,"githubUrl":"https://github.com/twpayne/chezmoi/blob/f901167e4685db90da56d6a2a19df642cb3e0247/internal/chezmoi/sourcestate.go#L2923-L2959","documentation":"This error is produced when chezmoi encounters a source file that looks like a script (e.g. its name starts with 'run_', 'runonce_', or 'before_') at a point where an actual script is required, but the entry does not satisfy the script criteria — most commonly when applying or validating the source state and a file matched by a script pattern is not actually usable as one. The format '%s: not a script' names the offending source-state target path. Common causes include a create_ or modify_ file whose target was passed to script handling, or a script-named entry of an unexpected kind (such as a directory or symlink) inside the source directory. To resolve it, inspect the named source entry in ~/.local/share/chezmoi: either rename it so it is treated as a regular managed file, or make it a proper script file with a supported prefix (run_, runonce_, before_) and executable content.","triggerScenarios":"Placing a regular (non-encrypted-suffix, non-script-named) file such as a data file, README, or helper config directly inside .chezmoiscripts so parseFileAttr resolves fa.Type != SourceFileTypeScript.","commonSituations":"Dropping helper files/notes into the scripts directory; scripts missing the required run_/before_/once_ style naming so their type parses as something else; encrypted payloads whose suffix makes them non-script.","solutions":["Rename the file with a script prefix (run_, run_once_, before_, etc.) so it parses as a script","Move non-script helper files elsewhere (e.g. .chezmoitemplates or a non-scripts source path)","Exclude auxiliary files from the scripts dir or mark them ignored with the ignore prefix"],"exampleFix":"// before\n.chezmoiscripts/notes.txt\n// after\n.chezmoitemplates/notes.txt  (or delete/rename to run_setup.sh)","handlingStrategy":"validation","validationCode":"#!/bin/sh\n# every regular file in .chezmoiscripts must parse as a script (script naming or encrypted script suffix)\nfor f in .chezmoiscripts/*; do\n  case \"$(basename \"$f\")\" in\n    run_*|run_once_*|run_onchange_*|before_*|before_once_*|*.encrypted) ;;\n    *) echo \"not a script: $f\"; exit 1;;\n  esac\ndone","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Name scripts with required prefixes (run_, run_once_, run_onchange_, before_, etc.)","Store non-script helpers in .chezmoitemplates or another allowed location","Add a pre-commit hook validating every file in .chezmoiscripts parses as a script"],"tags":["chezmoi","scripts","naming"],"backgroundTag":"not-a-script","analyzedSha":"f901167e4685db90da56d6a2a19df642cb3e0247","analyzedAt":"2026-09-01T18:16:41.508Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T01:17:15.007Z"}