{"id":"256310140ff8f8d4","repo":"gohugoio/hugo","slug":"failed-to-open-non-content-file-w","errorCode":null,"errorMessage":"failed to open non-content file: %w","messagePattern":"failed to open non-content file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"create/content.go","lineNumber":190,"sourceCode":"\t}\n\n\tif err := b.h.Build(hugolib.BuildCfg{NoBuildLock: true, SkipRender: true, ContentInclusionFilter: contentInclusionFilter}); err != nil {\n\t\treturn err\n\t}\n\n\tfor i, filename := range contentTargetFilenames {\n\t\tif err := b.applyArcheType(filename, b.dirMap.contentFiles[i]); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// Copy the rest as is.\n\tfor _, fi := range b.dirMap.otherFiles {\n\t\tmeta := fi.Meta()\n\n\t\tin, err := meta.Open()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to open non-content file: %w\", err)\n\t\t}\n\t\ttargetFilename := filepath.Join(baseDir, b.targetPath, strings.TrimPrefix(fi.Meta().Filename, b.archetypeFi.Meta().Filename))\n\t\ttargetDir := filepath.Dir(targetFilename)\n\n\t\tif err := b.sourceFs.MkdirAll(targetDir, 0o777); err != nil && !os.IsExist(err) {\n\t\t\treturn fmt.Errorf(\"failed to create target directory for %q: %w\", targetDir, err)\n\t\t}\n\n\t\tout, err := b.sourceFs.Create(targetFilename)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t_, err = io.Copy(out, in)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/create/content.go#L172-L208","documentation":"When `hugo new` runs with a directory archetype (bundle archetype), files inside it are split into content files (executed as templates) and 'other' files copied verbatim. This error occurs while copying an 'other' (non-content) file: opening the source file from the archetype filesystem via meta.Open() failed, wrapping the underlying OS error.","triggerScenarios":"contentBuilder.buildDir copying b.dirMap.otherFiles — e.g. an image or data file inside archetypes/<kind>/ — when Open() on that archetype file returns an error (permission denied, file deleted between walk and copy, broken symlink, I/O error).","commonSituations":"Unreadable file permissions inside the archetype directory; dangling symlinks in a theme's or module's archetype bundle; archetype files modified/removed concurrently; module-mounted archetype filesystems with access problems.","solutions":["Check the wrapped error for the OS cause and fix permissions on the file inside archetypes/ (chmod it readable).","Remove or fix broken symlinks in the archetype directory.","If the archetype comes from a module/theme, run `hugo mod verify`/re-vendor to restore intact files."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if fi, err := os.Stat(src); err != nil || !fi.Mode().IsRegular() {\n    return fmt.Errorf(\"archetype asset %q unreadable\", src)\n}","typeGuard":"func isNotExist(err error) bool { return errors.Is(err, fs.ErrNotExist) }","tryCatchPattern":"if err := create.NewContent(...); err != nil {\n    if errors.Is(err, fs.ErrNotExist) || errors.Is(err, fs.ErrPermission) {\n        // fix archetype bundle file permissions/paths\n    }\n    return err\n}","preventionTips":["Ensure files inside archetype bundles are readable (permissions, not symlinked outside the project)","Avoid broken symlinks in archetype directories","Test archetype bundles with hugo new after editing them"],"tags":["hugo","archetype","bundle","filesystem","permissions"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}