Standalone installer on macOS misclassifies npm installs under /usr/local as Homebrew and selects the wrong uninstall command

オープン 初心者向け
#64,476 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
88/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
macos, node.js, python, shell

調査の方向性

まず scripts/install/install.sh の classify_existing_codex() と handle_conflicting_install() から始め、次に scripts/install/test_install_sh.py のインストーラーのケースを読みます。最初に Python のインストーラーテストを実行し、Darwin における npm と Homebrew の分類を再現して現在の失敗を確認します。回帰テストが /usr/local 配下の npm launcher をカバーし、正当な Homebrew の検出を維持し、実際の package manager を呼び出さずに選択されたアンインストールコマンドを検証すれば、変更は完了입니다。

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

説明

bug CLI
Summary

The standalone CLI installer incorrectly identifies an npm-managed Codex executable under /usr/local/bin as Homebrew-managed on macOS. If a user accepts the offer to remove the previous installation, it selects brew uninstall --cask codex instead of npm uninstall -g @openai/codex.

This affects a normal npm global-install layout on macOS, particularly Intel Macs using the default /usr/local prefix. It can leave the old npm installation in place after migration, or attempt to uninstall a separate Homebrew installation if one exists.

Version / environment

Source reviewed: main at 065e18b. Verified the installer functions in an isolated Linux shell with the macOS branch selected (os=darwin), an npm-style symlink, and mocked package managers. A full native macOS install was not run.

Reproduction

On a macOS machine where command -v codex resolves to /usr/local/bin/codex and that symlink points to the npm package's bin/codex.js:

  1. Start the standalone installer.
  2. Observe its existing-install detection. No uninstallation is needed to reproduce the incorrect detection.

Alternatively, in a checkout of the pinned revision, run this non-destructive function-level reproduction with the npm installation present:

eval "$(sed -n '/^classify_existing_codex() {$/,/^}$/p' scripts/install/install.sh)"
os=darwin
BIN_PATH="$HOME/.local/bin/codex"
classify_existing_codex /usr/local/bin/codex

Expected: npm (or an unknown classification if ownership cannot be established).

Actual: brew.

The isolated test used a real symlink to a fixture with the Node shebang and mocked the user's acceptance and both uninstall commands. Observed output:

existing: /usr/local/bin/codex
shebang: #!/usr/bin/env node

OS branch: linux
Detected existing npm-managed Codex at /usr/local/bin/codex
Running: npm uninstall -g @openai/codex
mock npm: uninstall -g @openai/codex

OS branch: darwin
Detected existing brew-managed Codex at /usr/local/bin/codex
Running: brew uninstall --cask codex
mock brew: uninstall --cask codex

No real package was uninstalled.

Root cause

classify_existing_codex(), install.sh:1003–1034 returns brew for any path under /usr/local/* or /opt/homebrew/* on Darwin, before checking the Node shebang or actual package ownership. The directory prefix is not unique to Homebrew.

handle_conflicting_install(), install.sh:1106–1131 then chooses the uninstall command based on that classification.

Suggested fix

Resolve the existing executable's symlink and establish package-manager ownership before offering an uninstall. In particular, recognize a verified npm Codex launcher before the Homebrew heuristic, and require positive Homebrew cask ownership evidence instead of a shared directory prefix. For ambiguous ownership, warn about PATH conflicts without offering an automatic uninstall.

Add a regression case to scripts/install/test_install_sh.py: Darwin + npm launcher at a shared prefix must not yield brew; genuine Homebrew installs should still be recognized. Mock uninstall commands and assert the chosen command.

Related but distinct: #61010 concerned a native mise wrapper incorrectly detected by a whole-file shebang search; this report concerns the earlier unconditional Darwin prefix classification, which remains in the current source. #24035 concerns self-update dispatch on Linux rather than the standalone installer's uninstall selection.

主要言語
Rust
スター
136k
フォーク
21.6k
平均マージ
1分
マージ済み PR(30日)
999

環境構築

はじめの一歩

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

openai/codex のほかの issue

openai/codex の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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