{"record":{"id":"7e4a38fd9442d83e","repo":"gohugoio/hugo","slug":"failed-to-copy-module-to-vendor-dir-w","errorCode":null,"errorMessage":"failed to copy module to vendor dir: %w","messagePattern":"failed to copy module to vendor dir: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/client.go","lineNumber":246,"sourceCode":"\t\tif t.Mounts() == nil {\n\t\t\treturn fmt.Errorf(\"cannot vendor module %q, need at least one mount\", t.PathVersionQuery(false))\n\t\t}\n\n\t\tfmt.Fprintln(&modulesContent, \"# \"+t.PathVersionQuery(true)+\" \"+t.Version())\n\n\t\tdir := t.Dir()\n\n\t\tfor _, mount := range t.Mounts() {\n\t\t\tsourceFilename := filepath.Join(dir, mount.Source)\n\t\t\ttargetFilename := filepath.Join(vendorDir, t.PathVersionQuery(true), mount.Source)\n\t\t\tfi, err := c.fs.Stat(sourceFilename)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to vendor module: %w\", err)\n\t\t\t}\n\n\t\t\tif fi.IsDir() {\n\t\t\t\tif err := hugio.CopyDir(c.fs, sourceFilename, targetFilename, nil); err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"failed to copy module to vendor dir: %w\", err)\n\t\t\t\t}\n\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 {","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/modules/client.go#L228-L264","documentation":"Returned by Client.Vendor when hugio.CopyDir fails copying a mount whose source is a directory into _vendor. Fires after the source Stat succeeded (so the dir exists) but the recursive copy failed. Wrapped with %w.","triggerScenarios":"Running `hugo mod vendor` where a mount source is a directory and CopyDir hits a permission error, an unreadable sub-entry, a broken symlink, or the target filesystem (afero.Fs) rejects a write (e.g. read-only overlay, disk full).","commonSituations":"Filesystem permission issues in the module cache; broken symlinks inside a theme's assets/layouts dir; running vendor on a read-only working directory; CI with a tmpfs that fills up; Windows path-length limits on deeply nested vendor targets.","solutions":["Inspect the wrapped error for the OS-level cause (permission, ENOSPC, symlink).","Fix permissions on the module cache (chmod) and ensure the working dir is writable.","Remove or repair broken symlinks in the offending module directory.","Free disk space or raise tmpfs size if ENOSPC."],"exampleFix":"# before: module cache not readable\nsudo chown -R $USER $(go env GOMODCACHE)\n\n# after\nhugo mod vendor   # now succeeds","handlingStrategy":"try-catch","validationCode":"// Pre-check writability of the vendor target.\nfunc vendorDirWritable(dir string) error {\n    probe := filepath.Join(dir, \".writeprobe\")\n    if err := os.MkdirAll(dir, 0o755); err != nil {\n        return err\n    }\n    return os.WriteFile(probe, []byte(\"x\"), 0o644)\n}","typeGuard":null,"tryCatchPattern":"if err := client.Vendor(); err != nil {\n    if strings.Contains(err.Error(), \"failed to copy module to vendor dir\") {\n        // unwrap to inspect permission/space/symlink cause\n    }\n}","preventionTips":["Ensure the project dir and module cache are writable by the Hugo user.","Avoid broken symlinks inside theme directories.","Run vendor on a clean checkout."],"tags":["modules","vendoring","filesystem","copy","permissions"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}