oobabooga/textgen · error · FileNotFoundError

No model specified.

Error message

No model specified.

What it means

resolve_model_path() raises FileNotFoundError('No model specified.') when model_name_or_path is None. The resolver cannot guess a model: it first checks whether the argument is an existing filesystem path, and only then falls back to joining a models directory with the name. A None argument short-circuits both branches immediately.

Source

Thrown at modules/utils.py:109

        if len(get_available_models()) == 0:
            logger.error(f"No model is loaded. To get started: 1) Place a GGUF file in your {shared.user_data_dir}/models folder, 2) Go to the Model tab and select it")
            return False, f"No model is loaded. Place a GGUF model in your {shared.user_data_dir}/models folder, then select it in the Model tab."
        else:
            error_msg = "No model is loaded. Please select one in the Model tab."
            logger.error(error_msg)
            return False, error_msg

    return True, None


def resolve_model_path(model_name_or_path, image_model=False):
    """
    Resolves a model path, checking for a direct path
    before the default models directory.
    """

    if model_name_or_path is None:
        raise FileNotFoundError("No model specified.")

    path_candidate = Path(model_name_or_path)
    if path_candidate.exists():
        return path_candidate
    elif image_model:
        return Path(f'{shared.args.image_model_dir}/{model_name_or_path}')
    else:
        return Path(f'{shared.args.model_dir}/{model_name_or_path}')


def get_available_models():
    # Get all GGUF files
    gguf_files = get_available_ggufs()

    # Filter out non-first parts of multipart GGUF files
    filtered_gguf_files = []
    for gguf_path in gguf_files:
        filename = os.path.basename(gguf_path)

View on GitHub (pinned to ed888c71f2)

Solutions

  1. Pass an explicit model name or path: set the --model CLI argument or select a model in the UI before loading.
  2. If calling programmatically, check the variable is not None before calling and fail early with your own clearer message.
  3. Verify shared.args.model_dir contains the model folder you named, since a non-path name is resolved relative to that directory.
  4. For image models, confirm image_model_dir is configured when relying on name-based resolution.

Example fix

# before
path = resolve_model_path(shared.model_name)  # shared.model_name is None -> crash

# after
if not shared.model_name:
    raise SystemExit('No model selected. Pass --model <name-or-path> or pick one in the UI.')
path = resolve_model_path(shared.model_name)
Defensive patterns

Strategy: validation

Validate before calling

def has_model(name) -> bool:
    return name is not None and (Path(name).exists() or (shared.args.model_dir / name).exists())

# before loading:
if not shared.model_name:
    raise SystemExit('Select a model first: --model <name-or-path>')

Type guard

def is_model_ref(value) -> bool:
    return isinstance(value, str) and len(value.strip()) > 0

Try / catch

try:
    path = resolve_model_path(model_name)
except FileNotFoundError as e:
    if 'No model specified' in str(e):
        raise SystemExit('No model selected. Pass --model or choose one in the UI.') from e
    raise

Prevention

When it happens

Trigger: Calling model loading APIs with model_name_or_path=None — typically when a CLI flag (--model) or UI model selector was left empty, or when a caller reads the model id from config/shared state that was never populated (e.g. shared.model_name unset at load time).

Common situations: Fresh install where no default model is set; a script or extension calls load_model with a variable that failed earlier and silently became None; switching between model dirs where the previous value is cleared but not replaced; API call with the model field omitted.

Related errors


AI-assisted analysis of oobabooga/textgen@ed888c71f2 (2026-08-15). Data as JSON: /api/errors/0f0ff0c728584e38. Report an issue: GitHub.