{"record":{"id":"ecaa3b2019badb15","repo":"gohugoio/hugo","slug":"workingdir-is-too-short","errorCode":null,"errorMessage":"workingDir is too short","messagePattern":"workingDir is too short","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"hugofs/fs.go","lineNumber":110,"sourceCode":"\tpublishDir := cfg.GetString(\"publishDirDynamic\")\n\tif publishDir == \"\" {\n\t\tpublishDir = cfg.GetString(\"publishDir\")\n\t}\n\treturn workingDir, publishDir\n}\n\nfunc newFs(source, destination afero.Fs, workingDir, publishDir string) *Fs {\n\tif publishDir == \"\" {\n\t\tpanic(\"publishDir is empty\")\n\t}\n\n\tif workingDir == \".\" {\n\t\tworkingDir = \"\"\n\t}\n\n\t// Sanity check\n\tif IsOsFs(source) && len(workingDir) < 2 {\n\t\tpanic(\"workingDir is too short\")\n\t}\n\n\t// If this does not exist, it will be created later.\n\tabsPublishDir := paths.AbsPathify(workingDir, publishDir)\n\n\tpubFs := NewBasePathFs(destination, absPublishDir)\n\n\treturn &Fs{\n\t\tSource:             source,\n\t\tPublishDir:         pubFs,\n\t\tPublishDirServer:   pubFs,\n\t\tPublishDirStatic:   pubFs,\n\t\tOs:                 &afero.OsFs{},\n\t\tWorkingDirReadOnly: getWorkingDirFsReadOnly(source, workingDir),\n\t\tWorkingDirWritable: getWorkingDirFsWritable(source, workingDir),\n\t}\n}\n","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/hugofs/fs.go#L92-L128","documentation":"A panic in newFs (hugofs/fs.go:110) when the source filesystem is a real OS filesystem and len(workingDir) < 2. The check is skipped for in-memory test filesystems (MemMapFs) but enforced for OsFs to avoid operating relative to a root/empty path.","triggerScenarios":"Running Hugo against the OS filesystem with an empty or root working directory; calling NewDefault/NewFromOld with a config whose workingDir is '' (and not '.').","commonSituations":"CI or scripts that run from '/' or leave workingDir unset; a misconfigured -s/--source flag resolving to a single character.","solutions":["Run Hugo from a real project directory","Set workingDir to the project root as an absolute path of length >= 2","For tests, use an in-memory afero filesystem which skips this check"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if hugofs.IsOsFs(source) && len(workingDir) < 2 {\n    return nil, errors.New(\"workingDir too short for an OS filesystem\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run Hugo from a real project directory","Pass an absolute workingDir of length >= 2 for OS filesystems","Use an in-memory afero fs in tests to bypass the check"],"tags":["config","filesystem","panic","hugofs"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}