Skip to content

fix(updater): use login shell for tool lifecycle commands#4633

Open
JK-97 wants to merge 1 commit into
farion1231:mainfrom
JK-97:fix/codex-install-login-shell
Open

fix(updater): use login shell for tool lifecycle commands#4633
JK-97 wants to merge 1 commit into
farion1231:mainfrom
JK-97:fix/codex-install-login-shell

Conversation

@JK-97

@JK-97 JK-97 commented Jun 25, 2026

Copy link
Copy Markdown

Summary / 概述

修复 macOS 上 CC Switch GUI 执行工具安装/升级时因非登录 shell 导致 `npm: command not found` 的问题。

将 `run_tool_lifecycle_silently` 中的 `bash -c` 改为 `bash -lc`,使 `/etc/profile` 中的 `path_helper` 能被加载,
补全 GUI 应用缺失的 PATH(如 `/usr/local/bin``/opt/homebrew/bin`),从而找到 `npm``node` 等命令。

影响范围:macOS 上所有工具的 install 和 update 生命周期操作。
改动量:一个字符(`-c``-lc`)。

Related Issue / 关联 Issue

没有现成 issue,留空或填 N/A

Screenshots / 截图

image
| Before / 修改前 | After / 修改后 |
|-----------------|---------------|
| 安装 Codex 报错 "bash: line 3: npm: command not found" | 安装成功 |

没有实际截图的话删掉这个表格也行。

Checklist / 检查清单

- [x] `pnpm typecheck` passes / 通过 TypeScript 类型检查 
- [x] `pnpm format:check` passes / 通过代码格式检查
- [ ] `cargo clippy` passes (if Rust code changed) 
- [ ] Updated i18n files if user-facing text changed

Replace  with  in  so that
 (which invokes ) is sourced before executing
install/update commands. Without this, GUI apps on macOS inherit a minimal
PATH from launchd () and cannot find tools
like npm <command>

Usage:

npm install        install all the dependencies in your project
npm install <foo>  add the <foo> dependency to your project
npm test           run this project's tests
npm run <foo>      run the script named <foo>
npm <command> -h   quick help on <command>
npm -l             display usage info for all commands
npm help <term>    search for help on <term>
npm help npm       more involved overview

All commands:

    access, adduser, approve-scripts, audit, bugs, cache, ci,
    completion, config, dedupe, deny-scripts, deprecate, diff,
    dist-tag, docs, doctor, edit, exec, explain, explore,
    find-dupes, fund, get, help, help-search, init, install,
    install-ci-test, install-test, link, ll, login, logout, ls,
    org, outdated, owner, pack, ping, pkg, prefix, profile,
    prune, publish, query, rebuild, repo, restart, root, run,
    sbom, search, set, shrinkwrap, stage, star, stars, start,
    stop, team, test, token, trust, undeprecate, uninstall,
    unpublish, unstar, update, version, view, whoami

Specify configs in the ini-formatted file:
    /Users/shenmingjie/.npmrc
or on the command line via: npm <command> --key=value

More configuration info: npm help config
Configuration fields: npm help 7 config

npm@11.16.0 /opt/homebrew/lib/node_modules/npm that are installed in  or .

Fixes the "npm: command not found" error when installing Codex (and
other npm-based tools) from the CC Switch GUI on macOS.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@farion1231

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 7adf218708

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants