sgl-project/sglang · error · ValueError

No config file specified after --config flag!

Error message

No config file specified after --config flag!

What it means

The --config flag must be immediately followed by a file path. If --config is the last token in argv there is no value to consume, so the parser raises before attempting to open anything.

Source

Thrown at python/sglang/srt/utils/server_args_config_parser.py:97

        before_config = cli_args[:config_index]
        after_config = cli_args[config_index + 2 :]  # Skip --config and file path

        # Simple merge: config args + CLI args
        return config_args + before_config + after_config

    def _extract_config_file_path(self, args: List[str]) -> str:
        """Extract the config file path from arguments."""
        config_indices = [i for i, arg in enumerate(args) if arg == "--config"]

        if len(config_indices) > 1:
            raise ValueError("Multiple config files specified! Only one allowed.")

        if not config_indices:
            return None

        config_index = config_indices[0]
        if config_index == len(args) - 1:
            raise ValueError("No config file specified after --config flag!")

        return args[config_index + 1]

    def _parse_yaml_config(self, file_path: str) -> Dict[str, Any]:
        """
        Parse YAML configuration file and convert to argument list.

        Args:
            file_path: Path to the YAML configuration file

        Returns:
            List of arguments in format ['--key', 'value', ...]

        Raises:
            ValueError: If file is not YAML or cannot be read
        """
        self._validate_yaml_file(file_path)

View on GitHub (pinned to 0132848349)

Solutions

  1. Supply the path right after --config: `--config config.yaml`
  2. Verify the config-path variable is set before building the command line

Example fix

# before
python -m sglang.launch_server --model-path m --config
# after
python -m sglang.launch_server --model-path m --config config.yaml
Defensive patterns

Strategy: validation

Validate before calling

i = args.index("--config") if "--config" in args else -1
assert i == -1 or i + 1 < len(args), "--config must be followed by a path"

Prevention

When it happens

Trigger: A command line ending in --config, e.g. `... --config`, or a script that appends --config before a variable that expanded to empty.

Common situations: Typo/truncated command line, or `--config $CONFIG_FILE` where CONFIG_FILE is unset, leaving --config dangling.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/82bc4f051043e9b2. Report an issue: GitHub.