global update silently drops a platform-specific optional dependency

オープン
#10,173 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript, node.js
領域
backend, cli

調査の方向性

Start by tracing the global update path for npm install -g and how it handles aliased optionalDependencies; compare it with the local-install fix in issue #8645. The report gives a reproducible case with @openai/codex@latest on npm 11.18.0, where the platform package is missing after a successful update but returns after uninstalling and reinstalling. Identify the relevant tests for global updates and add coverage that verifies the platform dependency remains installed.

索引モデルが issue の本文から書いたものです。

説明

Bug cmd:update config:global Priority 2

https://github.com/npm/cli/issues/8628#issuecomment-6076454666

Still seeing this (or a closely related variant) on npm 11.18.0 — a global update silently drops a platform-specific optional dependency and exits 0. Posting here since #8645 supposedly fixed the local-install case in 11.6.3/11.6.4; the global path still appears affected.

Environment

  • npm: 11.18.0
  • Node.js: v22.23.1
  • OS: Linux x86_64
  • prefix: ~/.npm-global (non-default, via npm config set prefix)

What happened

  1. @openai/codex was already installed globally at an older version.

  2. Ran npm install -g @openai/codex@latest (this is also what Codex's built-in updater runs). Output: changed 2 packages in 29s, exit code 0.

  3. @openai/[email protected] declares its platform binaries through aliased optionalDependencies:

    "optionalDependencies": {
      "@openai/codex-linux-x64": "npm:@openai/[email protected]",
      "@openai/codex-linux-arm64": "npm:@openai/[email protected]",
      ...
    }
    
  4. After the update, ~/.npm-global/lib/node_modules/@openai/codex/node_modules/@openai/codex-linux-x64 was missing entirely, so the package's CLI fails at runtime with:

    Error: Missing optional dependency @openai/codex-linux-x64.
    Reinstall Codex: npm install -g @openai/codex@latest
    

    A plain re-run of npm install -g @openai/codex@latest (as the error message suggests) does not fix it — it again reports success while leaving the optional dep out.

Workaround that worked

npm uninstall -g @openai/codex && npm install -g @openai/codex@latest

A full uninstall + reinstall restores @openai/codex-linux-x64 correctly.

Happy to run diagnostics (npm ls -g, arborist logs, etc.) if helpful.

主要言語
JavaScript
スター
10.3k
フォーク
5k
平均マージ
4日 11時間
マージ済み PR(30日)
26

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

npm/cli のほかの issue

npm/cli の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。