{"record":{"id":"5443bda0c60896af","repo":"sgl-project/sglang","slug":"error-model-path-is-required-please-provide-th","errorCode":null,"errorMessage":"Error: --model-path is required. Please provide the path to the model.","messagePattern":"Error: --model-path is required\\. Please provide the path to the model\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"python/sglang/cli/utils.py","lineNumber":128,"sourceCode":"            break\n\n    return model_path\n\n\ndef get_model_path(extra_argv):\n    # Find the model_path argument\n    model_path = try_get_model_path(extra_argv)\n\n    if model_path is None:\n        # Fallback for --help or other cases where model-path is not provided\n        if any(h in extra_argv for h in [\"-h\", \"--help\"]):\n            raise Exception(\n                \"Usage: sglang serve --model-path <model-name-or-path> [additional-arguments]\\n\\n\"\n                \"This command can launch either a standard language model server or a diffusion model server.\\n\"\n                \"The server type is determined by the --model-path.\\n\"\n            )\n        else:\n            raise Exception(\n                \"Error: --model-path is required. \"\n                \"Please provide the path to the model.\"\n            )\n    return model_path\n\n\n@lru_cache(maxsize=1)\ndef get_git_commit_hash() -> str:\n    try:\n        commit_hash = os.environ.get(\"SGLANG_GIT_COMMIT\")\n        if not commit_hash:\n            commit_hash = (\n                subprocess.check_output(\n                    [\"git\", \"rev-parse\", \"HEAD\"], stderr=subprocess.DEVNULL\n                )\n                .strip()\n                .decode(\"utf-8\")\n            )","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/cli/utils.py#L110-L146","documentation":"Raised by get_model_path() when no --model-path can be found in the CLI arguments and no help flag is present — i.e. a plain missing-required-argument error. The serve command cannot proceed because server type (LLM vs diffusion) is determined from the model path.","triggerScenarios":"`sglang serve` with no --model-path; passing the model positionally or via an unsupported flag (e.g. --model) that try_get_model_path doesn't recognize.","commonSituations":"Users used to `sglang.launch_server --model-path` omitting it by mistake; scripts assuming a default model or an environment variable that the CLI does not read.","solutions":["Add --model-path /path/or/model-name to the command.","Check spelling of the flag: it must be exactly --model-path (or a recognized alias)."],"exampleFix":"# before\nsglang serve --port 30000\n# after\nsglang serve --model-path meta-llama/Llama-3-8B-Instruct --port 30000","handlingStrategy":"validation","validationCode":"if not any(a == \"--model-path\" or a.startswith(\"--model-path=\") for a in argv):\n    raise SystemExit(\"Error: --model-path is required.\")","typeGuard":null,"tryCatchPattern":"try:\n    model_path = get_model_path(extra_argv)\nexcept Exception as e:\n    if \"--model-path is required\" in str(e):\n        print(usage); exit(2)","preventionTips":["Require --model-path at argparse level so users get standard argparse errors.","Add a model-path presence check early in wrapper scripts."],"tags":["sglang","cli","missing-argument","model-path"],"backgroundTag":"missing-required-argument","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}