{"record":{"id":"bac84eb95295a190","repo":"gohugoio/hugo","slug":"failed-to-copy-q-to-q-w","errorCode":null,"errorMessage":"failed to copy %q to %q: %w","messagePattern":"failed to copy %q to %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/convert.go","lineNumber":248,"sourceCode":"\t\tskipDirs := make(map[string]bool)\n\t\trelToOutputDir, err := filepath.Rel(contentDir, outputDirAbs)\n\t\tif err == nil && relToOutputDir != \"..\" && !strings.HasPrefix(relToOutputDir, \"..\"+string(filepath.Separator)) {\n\t\t\tskipDirs[filepath.Clean(outputDirAbs)] = true\n\t\t}\n\t\trelToOutputContentDir, err := filepath.Rel(contentDir, outputContentDirAbs)\n\t\tif err == nil && relToOutputContentDir != \"..\" && !strings.HasPrefix(relToOutputContentDir, \"..\"+string(filepath.Separator)) {\n\t\t\tskipDirs[filepath.Clean(outputContentDirAbs)] = true\n\t\t}\n\n\t\tvar shouldCopy func(filename string) bool\n\t\tif len(skipDirs) > 0 {\n\t\t\tshouldCopy = func(filename string) bool {\n\t\t\t\treturn !skipDirs[filepath.Clean(filename)]\n\t\t\t}\n\t\t}\n\n\t\tif err := hugio.CopyDir(hugofs.Os, contentDir, outputContentDirAbs, shouldCopy); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to copy %q to %q: %w\", contentDir, outputContentDirAbs, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (c *convertCommand) convertContents(format metadecoders.Format) error {\n\tif c.outputDir == \"\" && !c.unsafe {\n\t\treturn newUserError(\"Unsafe operation not allowed, use --unsafe or set a different output path\")\n\t}\n\n\tif err := c.h.Build(hugolib.BuildCfg{SkipRender: true}); err != nil {\n\t\treturn err\n\t}\n\n\tsite := c.h.Sites[0]\n\n\tworkingDir := c.h.Sites[0].Deps.Conf.WorkingDir() + string(filepath.Separator)","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/commands/convert.go#L230-L266","documentation":"In copyContentDirsForOutput (convert.go:247-249), Hugo copies the content directory tree to the output directory using hugio.CopyDir. If any file or directory copy fails (source missing, read/write permission denied, disk full), the error is wrapped with the source and destination paths.","triggerScenarios":"A file in the content directory cannot be read or a file in the output directory cannot be written during the recursive copy performed by hugo convert with an --output path.","commonSituations":"Permission mismatch between source (read) and destination (write); files changed or removed during the copy; read-only destination; disk full.","solutions":["Check read permissions on the content source directory tree","Check write permissions and disk space on the output directory","Ensure files are not being modified by another process during conversion","Re-run after fixing permissions or clearing the output directory"],"exampleFix":"# before: output dir read-only\nhugo convert toYAML --output /mnt/readonly/out\n# after\nchmod -R u+w /mnt/readonly/out && hugo convert toYAML --output /mnt/readonly/out","handlingStrategy":"validation","validationCode":"// Pre-check read permission on source and write permission on destination.\nfunc checkCopyFeasible(src, dst string) error {\n    if info, err := os.Stat(src); err != nil || !info.IsDir() {\n        return fmt.Errorf(\"source %q not readable\", src)\n    }\n    return os.MkdirAll(dst, 0o755)\n}","typeGuard":null,"tryCatchPattern":"// Report copy failures with context and continue.\nif err := hugio.CopyDir(hugofs.Os, src, dst, nil); err != nil {\n    log.Printf(\"failed to copy %q to %q: %v\", src, dst, err)\n}","preventionTips":["Ensure the content source and output directories are both accessible by the Hugo user","Close other programs that might lock content files during conversion","Run hugo convert from a stable working tree"],"tags":["convert","filesystem","copy","cli","permissions","hugo"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}