{"record":{"id":"e48b29a964168abd","repo":"gohugoio/hugo","slug":"failed-to-copy-resources-to-vendor-dir-w","errorCode":null,"errorMessage":"failed to copy resources to vendor dir: %w","messagePattern":"failed to copy resources to vendor dir: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/client.go","lineNumber":266,"sourceCode":"\t\t\t} else {\n\t\t\t\ttargetDir := filepath.Dir(targetFilename)\n\n\t\t\t\tif err := c.fs.MkdirAll(targetDir, 0o755); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to make target dir: %w\", err)\n\t\t\t\t}\n\n\t\t\t\tif err := hugio.CopyFile(c.fs, sourceFilename, targetFilename); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to copy module file to vendor: %w\", err)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Include the resource cache if present.\n\t\tresourcesDir := filepath.Join(dir, files.FolderResources)\n\t\t_, err := c.fs.Stat(resourcesDir)\n\t\tif err == nil {\n\t\t\tif err := hugio.CopyDir(c.fs, resourcesDir, filepath.Join(vendorDir, t.PathVersionQuery(true), files.FolderResources), nil); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to copy resources to vendor dir: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\t// Include the config directory if present.\n\t\tconfigDir := filepath.Join(dir, \"config\")\n\t\t_, err = c.fs.Stat(configDir)\n\t\tif err == nil {\n\t\t\tif err := hugio.CopyDir(c.fs, configDir, filepath.Join(vendorDir, t.PathVersionQuery(true), \"config\"), nil); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to copy config dir to vendor dir: %w\", err)\n\t\t\t}\n\t\t}\n\n\t\t// Also include any theme.toml or config.* or hugo.* files in the root.\n\t\tconfigFiles, _ := afero.Glob(c.fs, filepath.Join(dir, \"config.*\"))\n\t\tconfigFiles2, _ := afero.Glob(c.fs, filepath.Join(dir, \"hugo.*\"))\n\t\tconfigFiles = append(configFiles, configFiles2...)\n\t\tconfigFiles = append(configFiles, filepath.Join(dir, \"theme.toml\"))\n\t\tfor _, configFile := range configFiles {","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/modules/client.go#L248-L284","documentation":"Returned by Client.Vendor when hugio.CopyDir fails copying the module's 'resources' directory (files.FolderResources) into _vendor, after the directory was confirmed to exist via Stat. Wrapped with %w. This is the post-mounts step that vendors the resource cache folder alongside mounts.","triggerScenarios":"Running `hugo mod vendor` for a module that contains a 'resources/' directory whose recursive copy fails: unreadable files, broken symlinks, permission errors, or a write rejection on the vendor target.","commonSituations":"Theme modules shipping a resources/_gen image cache with restrictive permissions; broken symlinks in resources; read-only _vendor; large resources dir hitting disk limits on CI; cross-filesystem copy where afero lacks support.","solutions":["Examine the wrapped error for the OS-level cause.","Fix permissions on the module's resources/ directory and re-run.","Remove unneeded contents from resources/_gen before vendoring.","Ensure _vendor is on a writable filesystem with enough space."],"exampleFix":"# before\nhugo mod vendor   # CopyDir on resources/ fails (perms)\n\n# after\nchmod -R u+r $(go env GOMODCACHE)/<module>@<ver>/resources\nhugo mod vendor","handlingStrategy":"try-catch","validationCode":"// Check the module's resources dir is readable before vendoring.\nfunc resourcesReadable(fs afero.Fs, dir string) error {\n    rd := filepath.Join(dir, \"resources\")\n    if _, err := fs.Stat(rd); err == nil {\n        f, err := fs.Open(rd)\n        if err != nil {\n            return err\n        }\n        f.Close()\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := client.Vendor(); err != nil {\n    if strings.Contains(err.Error(), \"failed to copy resources to vendor dir\") {\n        // inspect permissions/symlinks in module's resources/, fix, retry\n    }\n}","preventionTips":["Avoid committing broken symlinks into a theme's resources/ dir.","Ensure resources/ is readable in the module cache."],"tags":["modules","vendoring","filesystem","resources","copy","permissions"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}