{"id":"80d2dc243e728636","repo":"gohugoio/hugo","slug":"failed-to-resolve-output-path-q-w","errorCode":null,"errorMessage":"failed to resolve output path %q: %w","messagePattern":"failed to resolve output path %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/convert.go","lineNumber":224,"sourceCode":"\tcontentDirs := make(map[string]bool)\n\tfor _, p := range pagesBackedByFile {\n\t\tfilename := p.File().Filename()\n\t\tcontentDir := strings.TrimSuffix(filename, p.File().Path())\n\t\tif contentDir == filename {\n\t\t\tcontinue\n\t\t}\n\t\tcontentDirs[filepath.Clean(contentDir)] = true\n\t}\n\n\tvar contentDirList []string\n\tfor contentDir := range contentDirs {\n\t\tcontentDirList = append(contentDirList, contentDir)\n\t}\n\tslices.Sort(contentDirList)\n\n\toutputDirAbs, err := filepath.Abs(c.outputDir)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to resolve output path %q: %w\", c.outputDir, err)\n\t}\n\n\tfor _, contentDir := range contentDirList {\n\t\toutputContentDirAbs := filepath.Join(outputDirAbs, filepath.Base(contentDir))\n\n\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 {","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/commands/convert.go#L206-L242","documentation":"Returned by `hugo convert` with --output when `filepath.Abs(c.outputDir)` fails while preparing to copy content directories (commands/convert.go:222-224). filepath.Abs only fails when the process's current working directory cannot be determined (needed to absolutize a relative path), so this is a rare environment-level failure rather than a bad flag value.","triggerScenarios":"Running `hugo convert to* -o <relative-path>` from a working directory that has been deleted or unmounted after the shell started (os.Getwd fails), or from a directory the process no longer has permission to stat — e.g. a temp dir cleaned up by another process, or an NFS mount that went away.","commonSituations":"Shells left in directories that were deleted (`rm -rf` from another terminal, CI workspace cleanup); containers whose workdir was removed; network filesystems dropping mid-session.","solutions":["`cd` into a directory that actually exists (e.g. the site root) and re-run the command.","Pass an absolute path to -o/--output so no cwd resolution is needed.","If in CI/containers, ensure the working directory is created before hugo runs and not removed by a parallel cleanup step."],"exampleFix":"# before (cwd was deleted)\nhugo convert toYAML -o converted\n# after\ncd /path/to/site && hugo convert toYAML -o /path/to/site/converted","handlingStrategy":"validation","validationCode":"abs, err := filepath.Abs(outputDir)\nif err != nil {\n    return err\n}\nif err := os.MkdirAll(abs, 0o755); err != nil {\n    return fmt.Errorf(\"cannot create output dir %q: %w\", abs, err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed to resolve output path\") {\n    // re-run with an absolute, pre-created output directory\n}","preventionTips":["Pass absolute paths for the output directory; never rely on the process working directory","Create the output directory before invoking conversion","Avoid symlinked or mount-crossing output paths that break path resolution"],"tags":["hugo","convert","filesystem","environment"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}