github/copilot-sdk · error · RuntimeError

In-process FFI runtime library not found at

Error message

In-process FFI runtime library not found at '{full_library_path}'.

What it means

FfiRuntimeHost.create validates that the resolved native runtime library path exists and is a regular file before constructing the host. If the file is missing it raises this error rather than letting ctypes fail with a lower-level message.

Solutions

  1. Call get_or_download_cli()/ensure_runtime_library() first so the runtime library is downloaded to the expected path.
  2. Print and verify the resolved library_path; fix typos or stale configuration pointing at a removed install.
  3. Reinstall/re-download the Copilot runtime if the cache was deleted.
  4. Confirm the path is a file, not a directory.

Example fix

# before
host = FfiRuntimeHost.create(library_path="~/.cache/copilot/runtime.node")
# after
from pathlib import Path
lib = get_or_download_cli()  # ensure runtime exists
host = FfiRuntimeHost.create(library_path=str(Path(lib).expanduser().resolve()))
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
lib = Path(library_path).expanduser().resolve()
if not lib.is_file():
    get_or_download_cli()  # ensure runtime present

Type guard

def has_runtime_library(path: str) -> bool:
    p = Path(path).expanduser().resolve()
    return p.is_file()

Try / catch

try:
    host = FfiRuntimeHost.create(library_path)
except RuntimeError as e:
    if "not found" in str(e):
        get_or_download_cli()
        host = FfiRuntimeHost.create(library_path)

Prevention

When it happens

Trigger: Calling FfiRuntimeHost.create(library_path=...) with a path that does not exist or is a directory — typically a wrong cache path, an uninstall that removed runtime.node, or a platform key that was never downloaded.

Common situations: Cache directory cleaned between runs; calling create() before get_or_download_cli()/ensure_runtime_library(); typo'd or relative path that does not resolve to an existing file.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of github/copilot-sdk@cd8cf15dc3 (2026-09-09). Data as JSON: /api/errors/cdf0a3ca302f44d7. Report an issue: GitHub.

Appendix: source

Thrown at python/copilot/_ffi_runtime_host.py:387

    def process(self) -> _FfiProcessAdapter:
        """The ``subprocess.Popen``-shaped adapter for :class:`JsonRpcClient`."""
        return self._process

    @staticmethod
    def create(
        library_path: str,
        cli_entrypoint: str | None = None,
        environment: dict[str, str] | None = None,
        args: Sequence[str] = (),
    ) -> FfiRuntimeHost:
        """Load the runtime cdylib and prepare the host.

        Raises:
            RuntimeError: If the native runtime library cannot be found.
        """
        full_library_path = str(Path(library_path).resolve())
        if not Path(full_library_path).is_file():
            raise RuntimeError(
                f"In-process FFI runtime library not found at '{full_library_path}'."
            )
        full_entrypoint = (
            str(Path(cli_entrypoint).resolve()) if cli_entrypoint is not None else None
        )
        return FfiRuntimeHost(full_library_path, full_entrypoint, environment, args)

    def _build_argv(self) -> bytes:
        if self._cli_entrypoint is None:
            argv: list[str] = []
        elif self._cli_entrypoint.lower().endswith(".js"):
            argv = ["node", self._cli_entrypoint, "--embedded-host", "--no-auto-update"]
        else:
            argv = [self._cli_entrypoint, "--embedded-host", "--no-auto-update"]
        argv.extend(self._extra_args)
        return json.dumps(argv).encode("utf-8")

    def _build_env(self) -> bytes | None:

View on GitHub (pinned to cd8cf15dc3)