Skip to content

[Bug]: a package-manager reinstall of codex destroys the shim and its .opencodex-real backup, with no self-heal #2412

Description

@garysassano

Client or integration

Codex CLI

Area

Installation or packaging

Summary

When codex is installed by a version manager (mise, asdf, volta, and similar layouts), upgrading it overwrites the opencodex autostart shim and the codex.opencodex-real backup the shim depends on. Nothing detects or repairs this on the next ocx start / ocx ensure, and routing silently reverts to native — producing the misleading symptom reported in #2411.

Reproduction

  1. Install codex through a version manager so the binary lives under its install tree, e.g. mise at ~/.local/share/mise/installs/codex/latest/bin/codex.

  2. Install the opencodex autostart shim:

    ocx codex-shim install
  3. Upgrade codex through the version manager (this replaces the binary in place):

    mise upgrade codex
  4. Inspect the shim:

    ocx codex-shim status
    Codex autostart shim: wrapper present but not an opencodex shim at
    /home/<user>/.local/share/mise/installs/codex/latest/bin/codex;
    original backup missing at
    /home/<user>/.local/share/mise/installs/codex/latest/bin/codex.opencodex-real.
    
  5. Note that neither ocx start nor ocx ensure repairs or reports it, and that ocx service repair reports success while leaving the condition in place:

    ocx service repair
    # ✅ opencodex service repaired and serving on port 10100.
    
    ocx doctor | grep -A2 'Codex restart safety'
    #   !!  AT RISK after restart (installed service is disabled, stopped, or unhealthy; run 'ocx service repair')
    #        routing=opencodex-local, service=installed-but-unhealthy, shim=stale
  6. Timestamps confirm the sequence:

    stat -c '%y %n' ~/.local/share/mise/installs/codex/latest/bin/codex
    # 2026-08-20 22:23:45  (version-manager upgrade to 0.149.0)
    stat -c '%y %n' ~/.codex/config.toml
    # 2026-08-21 21:50:57  (no openai_base_url present)

Expected: the stale shim is detected and either repaired or reported prominently, rather than silently leaving routing native.

Actual: it is only visible via ocx codex-shim status or ocx doctor; ocx status stays green and routing quietly reverts.

Version

opencodex 2.29.0

Operating system

Ubuntu 24.04.4 LTS (WSL2, kernel 6.18.33.2-microsoft-standard-WSL2); codex-cli 0.149.0 installed via mise

Provider and model

Not model-specific — affects every routed model once the shim is stale.

Logs or error output

$ ocx codex-shim status
Codex autostart shim: wrapper present but not an opencodex shim at
/home/<user>/.local/share/mise/installs/codex/latest/bin/codex;
original backup missing at
/home/<user>/.local/share/mise/installs/codex/latest/bin/codex.opencodex-real.

$ ocx doctor | grep -A2 'Codex restart safety'
Codex restart safety
  !!  AT RISK after restart (installed service is disabled, stopped, or unhealthy; run 'ocx service repair')
       routing=opencodex-local, service=installed-but-unhealthy, shim=stale

Why it is awkward to fix locally: the shim replaces the codex binary in place, but under a version manager that binary is owned by the version manager and will be overwritten again on the next upgrade. Reinstalling the shim also cannot restore .opencodex-real, since the original was already overwritten.

Suggestions: (1) report the stale-shim condition in ocx status, not only in codex-shim status / doctor; (2) self-heal on ocx start / ocx ensure where safe, or fall back cleanly and say which; (3) document the version-manager interaction — for version-manager-owned codex, the openai_base_url config route alone may be the supported path, since the shim and the version manager contend for the same file.

Related: #2411 is the user-visible symptom this produces.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinginstallInstallation or packagingserviceService lifecycle (WinSW/launchd/scheduler)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions