{"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/8a468df065a75c1c7cf9f6850f32148746590ea5/modules/client.go#L248-L284","documentation":"In `hugo mod vendor` (modules/client.go:266), Hugo also vendors a module's `resources` directory (the resource/asset cache, e.g. processed images) when it exists, so vendored builds don't need to re-generate those resources. This error wraps a failure of that recursive CopyDir into _vendor/<module>/resources.","triggerScenarios":"The module directory contains a `resources` folder (Stat succeeds) but hugio.CopyDir to the vendor dir fails — unreadable cached resource files, write/permission errors under _vendor/, or disk exhaustion (resource caches can be large).","commonSituations":"Large image-processing caches filling the disk during vendoring; permission mismatches on resources generated by a different user/CI job; corrupted or partially written resource cache files.","solutions":["Check disk space — the resources cache is often the largest thing vendored.","Fix permissions on the module's resources directory and on the project _vendor target, then retry.","If the module's resource cache is corrupt or unneeded, remove it upstream (or in the module cache after go clean -modcache) and re-vendor; Hugo will regenerate resources at build time.","Read the wrapped error for the specific failing file."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// If the module has a resources cache dir, ensure it's intact\nresourcesDir := filepath.Join(mod.Dir(), \"resources\")\nif fi, err := os.Stat(resourcesDir); err == nil && !fi.IsDir() {\n    return fmt.Errorf(\"module resources path %q is not a directory\", resourcesDir)\n}","typeGuard":null,"tryCatchPattern":"if err := client.Vendor(); err != nil {\n    if strings.Contains(err.Error(), \"failed to copy resources to vendor dir\") {\n        // resources/ is a cache — clearing it in the module and re-vendoring is safe\n        return fmt.Errorf(\"module resources dir could not be copied; clear and retry: %w\", err)\n    }\n    return err\n}","preventionTips":["Treat the module's resources/ directory as a regenerable cache — it can be cleared if corrupt","Ensure enough disk space; resources dirs (processed images) can be large","Exclude huge generated resources from modules you publish so consumers don't vendor them"],"tags":["hugo","modules","vendoring","resources","filesystem"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}