{"record":{"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/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/modules/client.go#L257-L293","documentation":"Returned by Client.Vendor when hugio.CopyDir fails copying the module's 'config' directory into _vendor, after Stat confirmed it exists. Wrapped with %w. This step mirrors the resources copy but for the module's top-level config folder, so module config travels with the vendored copy.","triggerScenarios":"Running `hugo mod vendor` for a module that ships a 'config/' directory whose recursive copy fails for filesystem reasons (permissions, symlinks, disk space, read-only target).","commonSituations":"Module config dir containing platform-specific or symlinked files; restrictive permissions in the module cache; _vendor on a read-only mount; CI ephemeral filesystem limits.","solutions":["Inspect the wrapped error for the concrete OS failure.","Repair permissions or broken symlinks in the module's config/ directory.","Make _vendor writable and ensure free disk space.","Re-download the module cleanly (`hugo mod clean` then vendor) if the cache is corrupted."],"exampleFix":"# before\nhugo mod vendor   # config/ copy fails\n\n# after\nhugo mod clean\nhugo mod vendor","handlingStrategy":"try-catch","validationCode":"// Check the module's config dir is readable before vendoring.\nfunc configDirReadable(fs afero.Fs, dir string) error {\n    cd := filepath.Join(dir, \"config\")\n    if _, err := fs.Stat(cd); err == nil {\n        f, err := fs.Open(cd)\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 config dir to vendor dir\") {\n        // unwrap to find permission/symlink/space cause, fix, retry\n    }\n}","preventionTips":["Keep module config/ directories free of platform-specific symlinks.","Ensure _vendor is writable with adequate free space."],"tags":["modules","vendoring","filesystem","config-dir","copy","permissions"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}