Detect Vite+-managed Codex installs (#42071)

## Why

Vite+ launches Codex through the same JavaScript shim as npm, so Codex could
misidentify Vite+-owned installations and recommend npm for updates.

## What changed

- Detect Vite+ global installs from their package ownership metadata and pass a
  dedicated `CODEX_MANAGED_BY_VITE_PLUS` marker to the native binary.
- Represent Vite+ in install context and `codex doctor` output.
- Recommend `vp install -g @openai/codex` in update and repair flows for
  Vite+-managed installs.

See https://github.com/openai/codex/pull/30880.

GitOrigin-RevId: 8add724eefd31170a078086392609dbbd7f20b26
This commit is contained in:
Charlie Marsh
2026-09-01 15:12:53 +00:00
committed by copyberry
parent 82461c9990
commit d141438342
12 changed files with 114 additions and 10 deletions
+8
View File
@@ -875,6 +875,10 @@ fn installation_check(show_details: bool) -> DoctorCheck {
"managed by bun: {}",
env::var_os("CODEX_MANAGED_BY_BUN").is_some()
));
details.push(format!(
"managed by Vite+: {}",
env::var_os("CODEX_MANAGED_BY_VITE_PLUS").is_some()
));
details.push(format!(
"managed by pnpm: {}",
env::var_os("CODEX_MANAGED_BY_PNPM").is_some()
@@ -967,6 +971,7 @@ fn doctor_managed_by_npm(current_exe: Option<&Path>) -> bool {
fn inherited_managed_env_for_cargo_binary(current_exe: Option<&Path>) -> bool {
if env::var_os("CODEX_MANAGED_BY_NPM").is_none()
&& env::var_os("CODEX_MANAGED_BY_BUN").is_none()
&& env::var_os("CODEX_MANAGED_BY_VITE_PLUS").is_none()
&& env::var_os("CODEX_MANAGED_BY_PNPM").is_none()
{
return false;
@@ -1020,6 +1025,9 @@ fn describe_install_context(context: &InstallContext) -> String {
InstallMethod::Bun => {
describe_method_with_package_layout("bun", context.package_layout.as_ref())
}
InstallMethod::VitePlus => {
describe_method_with_package_layout("vite+", context.package_layout.as_ref())
}
InstallMethod::Pnpm => {
describe_method_with_package_layout("pnpm", context.package_layout.as_ref())
}
+1 -1
View File
@@ -1282,7 +1282,7 @@ Environment
LESS -FRX
✓ runtime running local build on darwin-arm64
✓ install consistent
managed by npm: no · bun: no · pnpm: no · package root —
managed by npm: no · bun: no · pnpm: no · Vite+: no · package root —
✓ search search is OK (bundled)
✓ git git version 2.54.0
selected git /usr/bin/git
+4 -1
View File
@@ -212,14 +212,16 @@ fn install_details(parsed: &[ParsedDetail], options: HumanOutputOptions) -> Vec<
let managed_by_npm = value(parsed, "managed by npm").unwrap_or("false");
let managed_by_bun = value(parsed, "managed by bun").unwrap_or("false");
let managed_by_pnpm = value(parsed, "managed by pnpm").unwrap_or("false");
let managed_by_vite_plus = value(parsed, "managed by Vite+").unwrap_or("false");
let package_root = value(parsed, "managed package root").unwrap_or("not set");
out.push(HumanDetail::Row {
label: "managed by".to_string(),
value: format!(
"npm: {} · bun: {} · pnpm: {} · package root {}",
"npm: {} · bun: {} · pnpm: {} · Vite+: {} · package root {}",
yes_no(managed_by_npm),
yes_no(managed_by_bun),
yes_no(managed_by_pnpm),
yes_no(managed_by_vite_plus),
if is_falsy(package_root) {
"—".to_string()
} else {
@@ -266,6 +268,7 @@ fn install_details(parsed: &[ParsedDetail], options: HumanOutputOptions) -> Vec<
"managed by npm",
"managed by bun",
"managed by pnpm",
"managed by Vite+",
"managed package root",
"PATH codex entries",
],
+1
View File
@@ -121,6 +121,7 @@ fn install_method_name(context: &InstallContext) -> &'static str {
InstallMethod::Standalone { .. } => "standalone",
InstallMethod::Npm => "npm",
InstallMethod::Bun => "bun",
InstallMethod::VitePlus => "vite+",
InstallMethod::Pnpm => "pnpm",
InstallMethod::Brew => "brew",
InstallMethod::Other => "local build",
@@ -30,7 +30,7 @@ Environment
→ Microsoft Defender: Add a certificate or executable-path exclusion for Codex and its helpers. If Attack Surface Reduction blocks Codex, add a rule exclusion. If Controlled Folder Access blocks Codex, allow the app.
✓ runtime running local build on darwin-arm64
✓ install consistent
managed by npm: no · bun: no · pnpm: no · package root —
managed by npm: no · bun: no · pnpm: no · Vite+: no · package root —
✓ search search is OK (bundled)
✓ git git version 2.54.0
selected git /usr/bin/git
+2
View File
@@ -432,6 +432,7 @@ fn update_action_label(context: &InstallContext) -> &'static str {
match &context.method {
InstallMethod::Npm => "npm install -g @openai/codex",
InstallMethod::Bun => "bun install -g @openai/codex",
InstallMethod::VitePlus => "vp install -g @openai/codex",
InstallMethod::Pnpm => "pnpm add -g @openai/codex",
InstallMethod::Brew => "brew upgrade --cask codex",
InstallMethod::Standalone { .. } => "standalone installer",
@@ -444,6 +445,7 @@ fn fetch_latest_version(context: &InstallContext) -> Result<String, String> {
InstallMethod::Brew => fetch_homebrew_cask_version(),
InstallMethod::Npm
| InstallMethod::Bun
| InstallMethod::VitePlus
| InstallMethod::Pnpm
| InstallMethod::Standalone { .. }
| InstallMethod::Other => fetch_latest_github_release_version(),