{"record":{"id":"ce68fdc3193aa8b3","repo":"gohugoio/hugo","slug":"must-not-be-run-from-the-file-system-root","errorCode":null,"errorMessage":"must not be run from the file system root","messagePattern":"must not be run from the file system root","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands/mod.go","lineNumber":272,"sourceCode":"\t\t\t\t\t}\n\n\t\t\t\t\tvar lastArg string\n\t\t\t\t\tif len(args) != 0 {\n\t\t\t\t\t\tlastArg = args[len(args)-1]\n\t\t\t\t\t}\n\n\t\t\t\t\tif lastArg == \"./...\" {\n\t\t\t\t\t\targs = args[:len(args)-1]\n\t\t\t\t\t\t// Do a recursive update.\n\t\t\t\t\t\tdirname, err := os.Getwd()\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Sanity chesimplecobra. We do recursive walking and want to avoid\n\t\t\t\t\t\t// accidents.\n\t\t\t\t\t\tif len(dirname) < 5 {\n\t\t\t\t\t\t\treturn errors.New(\"must not be run from the file system root\")\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfilepath.Walk(dirname, func(path string, info os.FileInfo, err error) error {\n\t\t\t\t\t\t\tif info.IsDir() {\n\t\t\t\t\t\t\t\treturn nil\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif info.Name() == \"go.mod\" {\n\t\t\t\t\t\t\t\t// Found a module.\n\t\t\t\t\t\t\t\tdir := filepath.Dir(path)\n\n\t\t\t\t\t\t\t\tcfg := config.New()\n\t\t\t\t\t\t\t\tcfg.Set(\"workingDir\", dir)\n\t\t\t\t\t\t\t\tconf, err := r.ConfigFromProvider(configKey{counter: r.configVersionID.Add(1)}, flagsToCfg(cd, cfg))\n\t\t\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\t\t\treturn err\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tr.Println(\"Update module in\", conf.configs.Base.WorkingDir)\n\t\t\t\t\t\t\t\tclient := conf.configs.ModulesClient","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/commands/mod.go#L254-L290","documentation":"`hugo mod ... ./...` performs a recursive module walk from the current directory. As a safety guard, if the working directory path is very short (len(dirname) < 5, i.e. the filesystem root), it refuses to run to prevent a recursive walk from / (mod.go:269-273).","triggerScenarios":"Running `hugo mod ... ./...` while the working directory is '/' or another path shorter than 5 characters.","commonSituations":"A CI container or shell whose cwd is /; running with cwd accidentally set to root; a script that cd'd to / before invoking hugo mod.","solutions":["cd into a project or workspace directory before running `hugo mod ... ./...`","Ensure your shell/CI cwd is a real project path, not /","Replace `./...` with an explicit module path if you must run from an unusual location"],"exampleFix":"# before (cwd is /)\nhugo mod npm ./...\n# after\ncd ~/code/mywork && hugo mod npm ./...","handlingStrategy":"validation","validationCode":"if dir, _ := os.Getwd(); len(dir) < 5 {\n    return errors.New(\"refusing recursive walk from filesystem root\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never run `hugo mod ... ./...` from /","Set an explicit, deep working directory in CI before module commands"],"tags":["modules","filesystem","safety","go","hugo","cli"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}