{"record":{"id":"b572814dcd5bbb2d","repo":"cli/cli","slug":"error-doc-path-not-set","errorCode":null,"errorMessage":"error: --doc-path not set","messagePattern":"error: --doc-path not set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"cmd/gen-docs/main.go","lineNumber":46,"sourceCode":"\nfunc run(args []string) error {\n\tflags := pflag.NewFlagSet(\"\", pflag.ContinueOnError)\n\tmanPage := flags.BoolP(\"man-page\", \"\", false, \"Generate manual pages\")\n\twebsite := flags.BoolP(\"website\", \"\", false, \"Generate website pages\")\n\tdir := flags.StringP(\"doc-path\", \"\", \"\", \"Path directory where you want generate doc files\")\n\thelp := flags.BoolP(\"help\", \"h\", false, \"Help about any command\")\n\n\tif err := flags.Parse(args); err != nil {\n\t\treturn err\n\t}\n\n\tif *help {\n\t\tfmt.Fprintf(os.Stderr, \"Usage of %s:\\n\\n%s\", filepath.Base(args[0]), flags.FlagUsages())\n\t\treturn nil\n\t}\n\n\tif *dir == \"\" {\n\t\treturn fmt.Errorf(\"error: --doc-path not set\")\n\t}\n\n\tios, _, _, _ := iostreams.Test()\n\trootCmd, _ := root.NewCmdRoot(&cmdutil.Factory{\n\t\tIOStreams: ios,\n\t\tBrowser:   &browser{},\n\t\tConfig: func() (gh.Config, error) {\n\t\t\treturn config.NewMockConfigFromString(\"\"), nil\n\t\t},\n\t\tExtensionManager: &em{},\n\t}, &telemetry.NoOpService{}, \"\", \"\")\n\trootCmd.InitDefaultHelpCmd()\n\n\tif err := os.MkdirAll(*dir, 0755); err != nil {\n\t\treturn err\n\t}\n\n\tif *website {","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/cli/cli/blob/0eeec0b92edbe70199f9768522f831d3534f41ad/cmd/gen-docs/main.go#L28-L64","documentation":"This is the gen-docs tool (cmd/gen-docs) that renders gh's manual pages. After parsing flags it requires --doc-path; an empty value returns this error and flags.PrintUsage output precedes it only when -h is given. It is a build-tooling flag error: the program generated docs have nowhere to be written.","triggerScenarios":"Running 'go run ./cmd/gen-docs' without arguments, or with --doc-path whose value is empty/unset in the wrapping Makefile target; also invoking the built binary in CI doc generation before the output directory variable is defined.","commonSituations":"Contributors generating docs locally forgetting the flag; release pipelines where the DOCS_PATH variable is empty due to a missing environment variable; refactors renaming the flag while old scripts pass --docs-path.","solutions":["Pass the flag explicitly: go run ./cmd/gen-docs --doc-path <dir>","In CI, default the variable: DOCS_PATH ?= ./docs in the Makefile target","Check for typos in the flag name (single dash -doc-path also works with pflag)"],"exampleFix":"# before\ngo run ./cmd/gen-docs\n# -> error: --doc-path not set\n\n# after\ngo run ./cmd/gen-docs --doc-path ./docs/man","handlingStrategy":"validation","validationCode":"// Shell: fail fast with a clear default\n: \"${DOCS_PATH:=./docs/man}\"\ngo run ./cmd/gen-docs --doc-path \"$DOCS_PATH\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default --doc-path in Makefile targets (DOCS_PATH ?= ./docs)","Set -u in scripts so empty variables fail visibly","Document the flag in release tooling READMEs"],"tags":["build-tooling","flags","documentation","ci"],"backgroundTag":null,"analyzedSha":"0eeec0b92edbe70199f9768522f831d3534f41ad","analyzedAt":"2026-08-15T12:31:05.478Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}