github/copilot-sdk · error

Could not resolve for Copilot CLI .

Error message

Could not resolve ${packageName} for Copilot CLI ${version}.

What it means

In the npm-package resolution path (COPILOT_CLI_USE_NPM_PACKAGE builds), ensureRuntimeBundle locates the per-platform package @github/copilot-<platform> via resolvePackageRoot. When it cannot be found it throws, naming the package and CLI version, because the bundled runtime.node is the only way to run Copilot CLI in this mode.

Solutions

  1. Install/restore the platform package matching getRuntimePlatform() output.
  2. Reinstall with optional dependencies enabled: npm install (avoid --omit=optional).
  3. Pass options.packageSearchPaths pointing at the node_modules roots that actually contain the package.
  4. For pnpm/PnP setups, add the platform package as a direct dependency so the linker keeps it.

Example fix

// before
npm install @github/copilot-sdk --omit=optional

// after
npm install @github/copilot-sdk @github/copilot-linux-x64
Defensive patterns

Strategy: validation

Validate before calling

import { resolvePackageRoot } from './runtimeArtifacts';
if (!resolvePackageRoot('@github/copilot-linux-x64', searchPaths)) throw new Error('platform package not installed');

Try / catch

try {
  const path = getBundledRuntimePath();
} catch (e) {
  if (e.message.startsWith('Could not resolve @github/copilot-')) {
    // install the named platform package or fix packageSearchPaths
  } else throw e;
}

Prevention

When it happens

Trigger: ensureRuntimeBundle (via getBundledRuntimePath/runtimePath) runs with the npm-package flag enabled and no entry for @github/copilot-<platform> in packageSearchPaths/node_modules.

Common situations: Internal canary builds installed without their platform package, pnpm/yarn PnP layouts not covered by search paths, trimmed production installs (--omit=optional), monorepo hoisting moving the package elsewhere.

Understand the failure class

Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.

Related errors


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

Appendix: source

Thrown at nodejs/src/runtimeArtifacts.ts:262

    packageName: string,
    searchPaths = require.resolve.paths(packageName) ?? []
): string | undefined {
    return searchPaths
        .map((base) => join(base, ...packageName.split("/")))
        .find((candidate) => existsSync(join(candidate, "package.json")));
}

export async function ensureRuntimeBundle(
    version: string,
    options: EnsureRuntimeBundleOptions = {}
): Promise<string> {
    const platform = options.platform ?? getRuntimePlatform();
    // lgtm[js/trivial-conditional] This generated constant is true for internal canary builds.
    if (COPILOT_CLI_USE_NPM_PACKAGE) {
        const packageName = `@github/copilot-${platform}`;
        const packageRoot = resolvePackageRoot(packageName, options.packageSearchPaths);
        if (!packageRoot) {
            throw new Error(`Could not resolve ${packageName} for Copilot CLI ${version}.`);
        }
        validateFile(
            join(packageRoot, "prebuilds", platform, "runtime.node"),
            "Copilot runtime.node"
        );
        return materializeRuntimeBundle(
            { packageRoot, platform },
            options.cacheRoot,
            `${version}-${platform}`
        );
    }

    const packageName = getRuntimePackageName(platform);
    const packageRoot = resolvePackageRoot(packageName, options.packageSearchPaths);
    if (!packageRoot) {
        throw new Error(
            `Could not resolve ${packageName}. Reinstall @github/copilot-sdk so its platform package is installed.`
        );

View on GitHub (pinned to cd8cf15dc3)