{"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/8a468df065a75c1c7cf9f6850f32148746590ea5/commands/convert.go#L230-L266","documentation":"Returned by `hugo convert` with --output when `hugio.CopyDir` fails to mirror a source content directory into the output directory (commands/convert.go:247-248). Before writing converted files, Hugo copies each content dir wholesale (skipping the output dir itself to avoid recursion); any I/O failure during that recursive copy — unreadable source entries, unwritable destination, disk full — surfaces here with both paths.","triggerScenarios":"Running `hugo convert to* -o <dir>` where a file under a content directory can't be read (permissions, broken symlink, file vanished mid-copy) or the destination can't be created/written (permission denied, disk full, destination path blocked by an existing file).","commonSituations":"Broken symlinks inside content/ (common after cloning repos that used symlinked shared content); mixed-ownership files from Docker; output directory on a full or read-only volume; antivirus/sync tools locking files on Windows.","solutions":["Read the wrapped error after the two paths — it names the specific file and syscall failure; fix that file first.","Remove or fix broken symlinks and unreadable files under the source content directory (`find content -xtype l`).","Ensure the output directory is on a writable volume with sufficient free space and that no existing file blocks a directory Hugo needs to create.","Re-run after fixing; the copy is per-content-dir, so one bad entry aborts that dir's copy."],"exampleFix":"# before: content/shared -> ../missing (broken symlink)\nhugo convert toYAML -o out\n# after\nrm content/shared && hugo convert toYAML -o out","handlingStrategy":"try-catch","validationCode":"src, err := os.Stat(from)\nif err != nil {\n    return fmt.Errorf(\"source missing: %w\", err)\n}\nif !src.Mode().IsRegular() {\n    return fmt.Errorf(\"%q is not a regular file\", from)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    var pathErr *fs.PathError\n    if errors.As(err, &pathErr) {\n        // identify which side (source read vs dest write) failed via pathErr.Path\n    }\n}","preventionTips":["Confirm source and destination are on writable, non-full filesystems before bulk copies","Don't run conversion while another process (editor, hugo server) holds the same files","Treat copy failures as fatal for that file and re-run only the failed subset after fixing the cause"],"tags":["hugo","convert","filesystem","copy"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}