{"id":"35eb03c9fe5859ed","repo":"gohugoio/hugo","slug":"failed-to-copy-config-dir-to-vendor-dir-w","errorCode":null,"errorMessage":"failed to copy config dir to vendor dir: %w","messagePattern":"failed to copy config dir to vendor dir: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/client.go","lineNumber":275,"sourceCode":"\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 {\n\t\t\tif err := hugio.CopyFile(c.fs, configFile, filepath.Join(vendorDir, t.PathVersionQuery(true), filepath.Base(configFile))); err != nil {\n\t\t\t\tif !herrors.IsNotExist(err) {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif modulesContent.Len() > 0 {","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/modules/client.go#L257-L293","documentation":"In `hugo mod vendor` (modules/client.go:275), Hugo copies a module's `config` directory (config/_default, environment configs, module imports) into _vendor/<module>/config when present, because that configuration must travel with the vendored module. This error wraps a failure of that recursive copy.","triggerScenarios":"The module has a `config` directory (Stat succeeds) but hugio.CopyDir(c.fs, configDir, <vendorDir>/<module>/config, nil) fails — permission or I/O errors reading the module's config tree or writing under _vendor/.","commonSituations":"Modules using the config-directory layout (config/_default/hugo.toml) vendored from a cache with odd permissions; read-only project checkouts; leftovers from a previous partial vendor conflicting with the target path; disk full.","solutions":["Delete _vendor and re-run hugo mod vendor to clear partial state.","Ensure read access to the module's config directory in the module cache and write access under the project.","Check the wrapped error's path for the specific file; fix its permissions or the disk-space issue.","If the cache seems corrupt, run go clean -modcache (or hugo mod clean) and re-download."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify the module's config dir before vendoring\ncfgDir := filepath.Join(mod.Dir(), \"config\")\nif fi, err := os.Stat(cfgDir); err == nil && !fi.IsDir() {\n    return fmt.Errorf(\"module config path %q is not a directory\", cfgDir)\n}","typeGuard":null,"tryCatchPattern":"if err := client.Vendor(); err != nil {\n    if strings.Contains(err.Error(), \"failed to copy config dir to vendor dir\") {\n        return fmt.Errorf(\"module's config/ dir could not be vendored — check permissions and symlinks: %w\", err)\n    }\n    return err\n}","preventionTips":["Keep module config directories (config/_default etc.) free of symlinks and special files","Vendor after config changes so _vendor stays in sync with the module's config dir","Delete and fully regenerate _vendor rather than hand-editing vendored config"],"tags":["hugo","modules","vendoring","config","filesystem"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}