{"record":{"id":"28dbc8aa03484b02","repo":"gohugoio/hugo","slug":"failed-to-load-modules-w","errorCode":null,"errorMessage":"failed to load modules: %w","messagePattern":"failed to load modules: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/allconfig/load.go","lineNumber":78,"sourceCode":"\n\tl := &configLoader{ConfigSourceDescriptor: d, cfg: config.New()}\n\t// Make sure we always do this, even in error situations,\n\t// as we have commands (e.g. \"hugo mod init\") that will\n\t// use a partial configuration to do its job.\n\tdefer l.deleteMergeStrategies()\n\tres, _, err := l.loadConfigMain(d)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load config: %w\", err)\n\t}\n\n\tconfigs, err = fromLoadConfigResult(d.Fs, d.Logger, res)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to create config from result: %w\", err)\n\t}\n\n\tmoduleConfig, modulesClient, err := l.loadModules(configs, d.IgnoreModuleDoesNotExist)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to load modules: %w\", err)\n\t}\n\n\tif len(l.ModulesConfigFiles) > 0 {\n\t\t// Config merged in from modules.\n\t\t// Re-read the config.\n\t\tconfigs, err = fromLoadConfigResult(d.Fs, d.Logger, res)\n\t\tif err != nil {\n\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","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/config/allconfig/load.go#L60-L96","documentation":"Wraps failures from configLoader.loadModules, which builds a modules.Client and calls Collect(). This resolves the project module, mounts, theme modules, Hugo Modules via Go (go.mod), and runs the HookBeforeFinalize that merges each module's config into the root. Failures include missing theme dir, module not found, go command unavailable, module import cycles, or errors while merging module config.","triggerScenarios":"`theme = \"mytheme\"` pointing at a non-existent themes/ entry; `[[module.imports]]` with a path/git URL that can't be resolved; Go toolchain missing when Go modules are used; a module whose config fails to merge; IgnoreModuleDoesNotExist=false and a referenced module is absent.","commonSituations":"Cloning a repo without `--recurse-submodules` or running `hugo mod tidy`; theme renamed/moved; vendored modules out of date; CI missing Go installation; a private module needing GOPRIVATE/GONOSUMCHECK setup.","solutions":["Verify the theme dir exists: `ls themes/<name>`.","Run `hugo mod tidy` then `hugo mod graph` to surface module resolution errors.","Ensure Go is installed and on PATH for Go-module-based themes.","Set IgnoreModuleDoesNotExist if a missing optional module is expected."],"exampleFix":"# before\ntheme = \"missing-theme\"\n\n# after\ntheme = \"my-theme\"  # matches themes/my-theme","handlingStrategy":"validation","validationCode":"# Confirm theme dir and Go toolchain exist\n[ -d \"themes/$THEME\" ] && echo \"theme ok\" || echo \"theme missing\"\ncommand -v go >/dev/null && echo \"go ok\" || echo \"go missing\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `hugo mod tidy` after pulling.","Pin theme/module versions in go.mod or module imports.","Ensure Go is installed for Go-module-based themes."],"tags":["modules","themes","config","go-modules"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}