Skip to content

fix(platform): honor CODEXHOST_INSTALL_ROOT on macOS - #457

Merged
BytePioneer-AI merged 1 commit into
BytePioneer-AI:mainfrom
akdoan1:fix/macos-honor-install-root
Oct 1, 2026
Merged

BytePioneer-AI merged 1 commit into
BytePioneer-AI:mainfrom
akdoan1:fix/macos-honor-install-root

Conversation

@akdoan1

@akdoan1 akdoan1 commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Summary

On macOS, discover_codex_desktop ignored CODEXHOST_INSTALL_ROOT and always probed /Applications/{Codex,ChatGPT}.app and ~/Applications/.... Windows honors the variable, and docs/platforms/macos/macos-native-tools.md says an explicit root is authoritative. As a result, codexhost, codexhost inspect, and the launcher could not target a Desktop bundle at another path (for example a second copy to run beside the stock app).

This change resolves an explicit root first through inspect_bundle and treats it as authoritative, including when invalid, with no fallback to the default locations. The default-candidate path is unchanged. The lookup is split into discover_with_custom_root so the precedence can be unit-tested without mutating process environment.

The bundle identifier and ASAR integrity checks still apply to the explicit root.

Related issues

N/A

Test plan

  • cargo test -p codexhost-platform --locked: 49 passed, 0 failed. This includes the new explicit_install_root_is_authoritative_over_default_candidates, which covers: a custom root wins without consulting defaults, defaults still work with no override, and an invalid custom root errors instead of falling back.
  • cargo clippy -p codexhost-platform --all-targets --locked -- -D warnings: clean.
  • cargo fmt --all: applied.
  • Manual, macOS arm64, Codex Desktop 26.928.21956: with CODEXHOST_INSTALL_ROOT pointing at a byte-identical copy of the bundle, codexhost inspect reports the copy as install_root (before the change it reported /Applications/ChatGPT.app), and Desktop launched from the copy beside the running stock app.
  • Not verified: Windows and Linux (code paths untouched).

macOS discovery ignored the explicit installation root and always probed the default app locations, unlike Windows and the documented behavior. Resolve an explicit root first and treat it as authoritative.
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: BytePioneer-AI/codex-host/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: a73f9f91-b539-49f7-bf96-52be0a0cabb8

📥 Commits

Reviewing files that changed from the base of the PR and between 01b4642 and 5eba4f6.

📒 Files selected for processing (1)
  • crates/platform/src/installation.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📜 Recent review details
🔇 Additional comments (1)
crates/platform/src/installation.rs (1)

1009-1015: LGTM!

Also applies to: 1017-1032, 1065-1067, 1151-1177


📝 Summary

Summary by CodeRabbit

  • 修复
    • 设置自定义安装目录时,现在仅在该目录查找 Codex 桌面版;若未找到有效安装,不会回退到默认目录。
    • 未设置自定义目录时,仍会在系统和用户应用目录中查找默认安装。

Walkthrough

macOS 的 Codex Desktop 安装发现现在支持自定义安装根目录。未设置自定义根目录时,发现流程继续检查系统和用户应用目录中的默认候选项。新增测试覆盖这些查找路径及无效 bundle 的错误处理。

Changes

macOS 安装发现

Layer / File(s) Summary
自定义根目录查找与候选项验证
crates/platform/src/installation.rs
新增查找辅助函数。设置自定义根目录时仅检查该 bundle;未设置时检查默认候选项。新增测试验证两种查找路径,以及无效自定义 bundle 返回 PlatformError::Invalid。

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: bytepioneer-ai

Merge Risk: ⚪ Minimal · up to 5eba4

The change honors the macOS installation-root override while retaining bundle validation and default discovery without an override. No merge-blocking issue is identified; merge after normal checks pass.

Architecture Summary

Architecture risk: 🟡 Medium · up to 5eba4

The change affects 1 system.

Changed systems: crates

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — crates (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in crates/platform/src/installation.rs: 新增 macOS 查找辅助函数:有自定义根目录时直接检查该 bundle;否则调用默认候选查找。
  • observed — Modified behavior in crates/platform/src/installation.rs: discover_codex_desktop 现在将自定义根目录传给查找辅助函数;未设置时仍生成 /Applications 和 ~/Applications 下的 Codex、ChatGPT 候选,原先直接查找这些候选的实现被替换。
  • observed — Modified behavior in crates/platform/src/installation.rs: macOS 测试模块新增导入 discover_with_custom_root。
  • observed — Modified behavior in crates/platform/src/installation.rs: 新增测试验证自定义 bundle 存在时不调用默认候选、未设置自定义根目录时使用默认候选,以及自定义 bundle 无效时返回 PlatformError::Invalid。

Reliability and maintainability

  • inferred — Risk-relevant change factors for crates: blast_radius_1; direct_dependents_1
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了主要变更:让 macOS 遵循 CODEXHOST_INSTALL_ROOT。标题简洁、明确,并与变更内容一致。
Description check ✅ Passed 描述说明了 macOS 安装根目录解析、显式路径优先级、测试结果和未验证的平台。内容与变更集直接相关。
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@BytePioneer-AI
BytePioneer-AI merged commit 79958a7 into BytePioneer-AI:main Oct 1, 2026
1 check passed
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