Skip to content

[Bug]: WSL service state records ~/.codex instead of the runtime-detected Windows Codex home #1400

Description

@Ted151951

Client or integration

Codex App

Area

Service lifecycle; Platform (Windows / Linux / WSL)

Summary

In the Windows Codex Desktop + WSL app-server layout supported by #63, OpenCodex uses two different Codex-home resolvers.

Runtime/config paths use the WSL-aware resolver and discover the Windows Desktop home. Service install state instead uses CODEX_HOME || homedir()/.codex. A service installed from an ordinary WSL shell therefore records the Linux fallback in service-state.json, even though the proxy runtime resolves the Windows Codex home.

Later service repair or service uninstall commands run from the Desktop-injected environment report a false ownership mismatch or direct restore logic toward the wrong home.

Expected: service ownership metadata should use the same canonical resolver as the proxy runtime, without requiring CODEX_HOME to be baked into the systemd environment.

Reproduction

  1. Use Windows Codex Desktop with the agent running in WSL2.

  2. Ensure Linux ~/.codex/config.toml is absent and exactly one Windows Codex config is visible at /mnt/c/Users/<windows-user>/.codex/config.toml.

  3. Run:

    env -u CODEX_HOME -u OPENCODEX_HOME ocx status

    OpenCodex correctly reports /mnt/c/Users/<windows-user>/.codex.

  4. Install the Linux user service from the same ordinary WSL environment:

    env -u CODEX_HOME -u OPENCODEX_HOME ocx service install
  5. Inspect ~/.opencodex/service-state.json. Its codexHome is /home/<wsl-user>/.codex.

  6. From a Codex Desktop WSL task, where CODEX_HOME=/mnt/c/Users/<windows-user>/.codex, run ocx service repair.

  7. Observe the ownership mismatch between the recorded Linux home and the Desktop home.

Code path:

function currentCodexHome(): string {
  const raw = process.env.CODEX_HOME?.trim();
  return raw ? resolve(expandUserPath(raw)) : join(homedir(), ".codex");
}

This bypasses the WSL-aware resolver already used by normal runtime paths.

Version

2.11.1

Operating system

Windows 11 with WSL2 / Ubuntu; Codex Desktop agent mode set to WSL

Logs or error output

Service was installed with CODEX_HOME=/home/<wsl-user>/.codex,
but current CODEX_HOME=/mnt/c/Users/<windows-user>/.codex.

Redacted configuration

{
  "desktopAgentMode": "WSL",
  "linuxConfigPresent": false,
  "windowsCodexHomeCandidates": 1
}

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Relationship

Follow-up to #63. Companion split-SQLite issue: #1401.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingplatformOS/service/tray/ACL (Windows-heavy, not Windows-only)serviceService lifecycle (WinSW/launchd/scheduler)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions