{"record":{"id":"6c2145d28558b993","repo":"gohugoio/hugo","slug":"failed-to-init-config-w","errorCode":null,"errorMessage":"failed to init config: %w","messagePattern":"failed to init config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/allconfig/load.go","lineNumber":104,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"failed to create config from modules config: %w\", err)\n\t\t}\n\t\tif err := configs.transientErr(); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to create config from modules config: %w\", err)\n\t\t}\n\t\tconfigs.LoadingInfo.ConfigFiles = append(configs.LoadingInfo.ConfigFiles, l.ModulesConfigFiles...)\n\t} else if err := configs.transientErr(); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create config: %w\", err)\n\t}\n\n\tconfigs.Modules = moduleConfig.AllModules\n\tconfigs.ModulesClient = modulesClient\n\n\tif !d.SkipNpmCheck && npm.NpmPackNeedsUpdate(d.Fs, configs.Modules) {\n\t\td.Logger.Warnln(`npm dependencies are out of sync, please run \"hugo mod npm pack\" (you may also want to run \"npm install\" after that)`)\n\t}\n\n\tif err := configs.Init(d.Fs, d.Logger); err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to init config: %w\", err)\n\t}\n\n\tloggers.SetGlobalLogger(d.Logger)\n\n\treturn\n}\n\n// ConfigSourceDescriptor describes where to find the config (e.g. config.toml etc.).\ntype ConfigSourceDescriptor struct {\n\tFs     afero.Fs\n\tLogger loggers.Logger\n\n\t// Config received from the command line.\n\t// These will override any config file settings.\n\tFlags config.Provider\n\n\t// Path to the config file to use, e.g. /my/project/config.toml\n\tFilename string","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/config/allconfig/load.go#L86-L122","documentation":"Wraps failures from Configs.Init, the finalization step that builds langs.Languages from the decoded config, filters disabled languages, initializes ConfiguredDimensions (languages/versions/roles matrix), constructs the content PathParser, runs each decoder's getInitializer/InitConfig, asserts at least one module loaded, and applies default project mounts. Any of these failing returns here.","triggerScenarios":"An invalid language configuration where a sorted language name has no matching LanguageConfigMap entry (\"invalid language configuration for %q\"); langs.NewLanguage failing (e.g. bad timezone); ConfiguredDimensions.Init failing; InitConfig failing for a section like permalinks/cascade; `no modules loaded (need at least the main module)`; modules.ApplyProjectConfigDefaults failing on bad mounts.","commonSituations":"Setting `timeZone` to an invalid zone; misconfigured module mounts; enabling multilingual/versions/roles in an inconsistent combination; a project with no main module (empty module config).","solutions":["Read the wrapped error: it pinpoints the init sub-step (language, dimensions, mounts, modules).","Validate `timeZone` against the IANA timezone database.","Confirm module mounts use valid source/target paths and readable dirs.","Ensure at least the main project module is present (project root acts as main module normally)."],"exampleFix":"# before\ntimeZone = \"Mars/Olympus\"\n\n# after\ntimeZone = \"Europe/Oslo\"","handlingStrategy":"validation","validationCode":"python3 - <<'PY'\nimport tomllib\ncfg=tomllib.loads(open('hugo.toml').read())\ntz=cfg.get('timeZone')\nif tz:\n    import zoneinfo\n    try: zoneinfo.ZoneInfo(tz)\n    except Exception as e: print(f\"bad timeZone {tz!r}: {e}\")\nprint(\"init prereqs ok\")\nPY","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use an IANA timezone for `timeZone`.","Validate module mounts resolve to existing dirs.","Ensure the project root is recognized as the main module."],"tags":["config","initialization","languages","modules"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}