global update silently drops a platform-specific optional dependency

Aperta
#10,173 1 commento 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript, node.js
Ambito
backend, cli

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
JavaScript
Stelle
10.3k
Fork
5k
Merge medio
4g 11h
PR unite (30g)
26

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di npm/cli

Tutte le issue di npm/cli

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.