{"id":"65643fee44b58d07","repo":"gohugoio/hugo","slug":"no-filesystem-provided","errorCode":null,"errorMessage":"no filesystem provided","messagePattern":"no filesystem provided","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/allconfig/load.go","lineNumber":333,"sourceCode":"\t\t} else {\n\t\t\treturn strings.Fields(v)\n\t\t}\n\tdefault:\n\t\treturn v\n\t}\n}\n\nfunc (l *configLoader) loadConfigMain(d ConfigSourceDescriptor) (config.LoadConfigResult, modules.ModulesConfig, error) {\n\tvar res config.LoadConfigResult\n\n\tif d.Flags != nil {\n\t\tif err := l.normalizeCfg(d.Flags); err != nil {\n\t\t\treturn res, l.ModulesConfig, err\n\t\t}\n\t}\n\n\tif d.Fs == nil {\n\t\treturn res, l.ModulesConfig, errors.New(\"no filesystem provided\")\n\t}\n\n\tif d.Flags != nil {\n\t\tif err := l.applyFlagsOverrides(d.Flags); err != nil {\n\t\t\treturn res, l.ModulesConfig, err\n\t\t}\n\t\tworkingDir := filepath.Clean(l.cfg.GetString(\"workingDir\"))\n\n\t\tl.BaseConfig = config.BaseConfig{\n\t\t\tWorkingDir: workingDir,\n\t\t\tThemesDir:  paths.AbsPathify(workingDir, l.cfg.GetString(\"themesDir\")),\n\t\t}\n\n\t}\n\n\tnames := d.configFilenames()\n\n\tif names != nil {","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/gohugoio/hugo/blob/8a468df065a75c1c7cf9f6850f32148746590ea5/config/allconfig/load.go#L315-L351","documentation":"`loadConfigMain` requires `ConfigSourceDescriptor.Fs` (an afero filesystem) to read config files from. When it is nil, config loading fails fast with this error rather than defaulting to the OS filesystem — Hugo deliberately has no fallback here.","triggerScenarios":"Programmatic use of `allconfig.LoadConfig` (or `hugolib` deps setup) passing a `ConfigSourceDescriptor` with a nil `Fs` field. Not reachable through the normal `hugo` CLI, which always wires `hugofs.Os`.","commonSituations":"Embedding Hugo as a library (custom build tools, tests) and forgetting to set `Fs: hugofs.Os` or an `afero.MemMapFs`; refactors that construct the descriptor in a new code path without the filesystem.","solutions":["Set the `Fs` field on `ConfigSourceDescriptor`, e.g. `Fs: hugofs.Os` for a real filesystem or `afero.NewMemMapFs()` in tests.","If using hugolib test helpers, use `hugolib.Test`/siblings, which wire the filesystem for you.","Trace where the descriptor is constructed and ensure the filesystem is threaded through every call path."],"exampleFix":"// before\nres, err := allconfig.LoadConfig(allconfig.ConfigSourceDescriptor{Flags: flags})\n// after\nres, err := allconfig.LoadConfig(allconfig.ConfigSourceDescriptor{Fs: hugofs.Os, Flags: flags})","handlingStrategy":"validation","validationCode":"if d.Fs == nil {\n    return errors.New(\"configure a filesystem (e.g. hugofs.NewDefault) before loading config\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always populate the Fs field of ConfigSourceDescriptor before calling the loader","Use a constructor/helper that requires the filesystem as a parameter instead of building the struct literal by hand","Add a unit test asserting your setup path passes a non-nil afero.Fs"],"tags":["hugo","config","filesystem","api-usage","go"],"analyzedSha":"8a468df065a75c1c7cf9f6850f32148746590ea5","analyzedAt":"2026-07-31T21:23:07.045Z","schemaVersion":2}