github/spec-kit · error · ValueError

Directory not found: {source_path}

Error message

Directory not found: {source_path}

What it means

When an init extension argument looks like a local path (`./`, `../`, `/`, `~/`, or an absolute path), Spec Kit expands and resolves it, then requires the target to exist. A missing directory becomes ValueError and the corresponding extension step is marked failed.

Source

Thrown at src/specify_cli/commands/init.py:122

    manager = ExtensionManager(project_path)

    # --- URL ---
    parsed = urlparse(ext_spec)
    if parsed.scheme in ("http", "https"):
        try:
            manifest = install_extension_from_url(
                manager, project_path, ext_spec, speckit_version
            )
        except ExtensionError as exc:
            raise ValueError(str(exc)) from exc
        return f"{manifest.name} v{manifest.version} installed"

    # --- Local path ---
    if ext_spec.startswith(("./", "../", "/", "~/", ".\\", "..\\")) or Path(ext_spec).is_absolute():
        source_path = Path(ext_spec).expanduser().resolve()
        if not source_path.exists():
            raise ValueError(f"Directory not found: {source_path}")
        if not (source_path / "extension.yml").exists():
            raise ValueError(f"No extension.yml found in {source_path}")
        manifest = manager.install_from_directory(source_path, speckit_version)
        return f"{manifest.name} v{manifest.version} installed"

    # --- Bundled extension name or catalog ID ---
    bundled_path = _locate_bundled_extension(ext_spec)
    if bundled_path is not None:
        if manager.registry.is_installed(ext_spec):
            return "already installed"
        manifest = manager.install_from_directory(bundled_path, speckit_version)
        return f"{manifest.name} v{manifest.version} installed"

    # Fall back to catalog
    catalog = ExtensionCatalog(project_path)
    ext_info, catalog_error = _resolve_catalog_extension(ext_spec, catalog, "add")
    if catalog_error:
        raise ValueError(f"Could not query extension catalog: {catalog_error}")

View on GitHub (pinned to bf88c9f9a8)

Solutions

  1. Run `ls` on the exact expanded path shown in the error from the same shell where you run specify.
  2. Correct the typo or change to the directory that contains the extension before running init.
  3. Create the extension directory first if it has not been written yet.
  4. Remember that a relative source must start with ./ or ../; a bare name is interpreted as a bundled/catalog extension id.

Example fix

# before
specify init demo --extension ./extentions/my-ext

# after
specify init demo --extension ./extensions/my-ext
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

def extension_source_dir_exists(ext_spec: str) -> bool:
    if not ext_spec.startswith(("./", "../", "/", "~/")) and not Path(ext_spec).is_absolute():
        return False
    return Path(ext_spec).expanduser().resolve().exists()

Try / catch

try:
    _install_extension_during_init(project_path, ext_spec, version)
except ValueError as exc:
    if str(exc).startswith("Directory not found:"):
        prompt_for_correct_extension_path()
    else:
        raise

Prevention

When it happens

Trigger: `specify init --extension ./my-ext` (or ../my-ext, /abs/my-ext, ~/my-ext) when the resolved directory does not exist. The path is resolved from the process's current working directory, not from the new project directory.

Common situations: Typo in the directory name, running `specify init` from a different shell directory, or forgetting to clone/create the extension first.

Related errors


AI-assisted analysis of github/spec-kit@bf88c9f9a8 (2026-08-14). Data as JSON: /api/errors/21c0d86894727fa6. Report an issue: GitHub.