1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Corepack の `Error: Cannot find matching keyid: ...` エラーに関して

Posted at

事象

久しぶりに Corepack を使用している Docker コンテナを立ち上げると以下のようなエラーが発生した

 => ERROR [frontend 5/5] RUN pnpm config set store-dir /pnpm/store                                                                                 0.4s
------
 > [frontend 5/5] RUN pnpm config set store-dir /pnpm/store:
0.325 /usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:21535
0.325   if (key == null || signature == null) throw new Error(`Cannot find matching keyid: ${JSON.stringify({ signatures, keys })}`);
0.325                                               ^
0.325
0.325 Error: Cannot find matching keyid: {"signatures":[{"sig":"~","keyid":"SHA256:~"}],"keys":[{"expires":null,"keyid":"SHA256:~","keytype":"ecdsa-sha2-nistp256","scheme":"ecdsa-sha2-nistp256","key":"~"}]}
0.325     at verifySignature (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:21535:47)
0.325     at fetchLatestStableVersion (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:21553:5)
0.325     at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
0.325     at async fetchLatestStableVersion2 (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:21672:14)
0.325     at async Engine.getDefaultVersion (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22298:23)
0.325     at async Engine.executePackageManagerRequest (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:22396:47)
0.325     at async Object.runMain (/usr/local/lib/node_modules/corepack/dist/lib/corepack.cjs:23102:5)
0.325
0.325 Node.js v22.13.1
------
failed to solve: process "/bin/sh -c pnpm config set store-dir ${PNPM_HOME}/store" did not complete successfully: exit code: 1

解決方法

If your builds suddenly fail with messages like cannot find matching keyid: {"signatures":[...],"keys":[...]}, it usually means npm registry keys have been rotated, and your older Corepack can’t verify new versions of pnpm (like 9.15.4 or 10.1.0+).

npm のレジストリキーがローテーションしたことにより、Corepack が新しいバージョンの pnpm を検証できなくなったことが原因

  1. If You’re on Node 18+ (or Newer)
    Upgrade to the latest Corepack (≥ 0.31.0):

今回 Node 22 を使用していたので、以下のように Corepack を有効化する前に最新バージョンへ更新してあげることで解決した

RUN npm install -g corepack@latest
RUN corepack enable
RUN pnpm config set store-dir ${PNPM_HOME}/store

その他参考

以下記事では Corepack の署名検証などに関しても解説されてました

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?