-
Notifications
You must be signed in to change notification settings - Fork 0
[WRONG BRANCH] fix(service): accept legacy WSL ownership state #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -241,6 +241,17 @@ export function serviceHomeMatches(a: string, b: string): boolean { | |
| return normalizePathForCompare(a) === normalizePathForCompare(b); | ||
| } | ||
|
|
||
| /** Accept the Linux default written by service versions predating WSL home discovery. */ | ||
| export function serviceCodexHomeMatchesInstall(recordedHome: string, deps: CodexHomeDeps = {}): boolean { | ||
| const actualHome = currentCodexHome(deps); | ||
| if (serviceHomeMatches(recordedHome, actualHome)) return true; | ||
|
|
||
| const env = deps.env ?? process.env; | ||
| if (env.CODEX_HOME?.trim() || !isWslRuntime(deps)) return false; | ||
| const legacyDefault = join((deps.homedir ?? homedir)(), ".codex"); | ||
| return serviceHomeMatches(recordedHome, legacyDefault); | ||
| } | ||
|
|
||
| /** Single accessor for backend-sensitive service code — v1/legacy state maps to scheduler. */ | ||
| export function readServiceBackend(): ServiceBackend { | ||
| return readServiceInstallState()?.backend === "native" ? "native" : "scheduler"; | ||
|
|
@@ -299,9 +310,7 @@ export function assertServiceEnvironmentMatchesInstall(): void { | |
| const state = readServiceInstallState(); | ||
| if (!state) return; | ||
| const actualCodexHome = currentCodexHome(); | ||
| const expected = normalizePathForCompare(state.codexHome); | ||
| const actual = normalizePathForCompare(actualCodexHome); | ||
| if (expected !== actual) { | ||
| if (!serviceCodexHomeMatchesInstall(state.codexHome)) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
In WSL, home discovery depends on live Useful? React with 👍 / 👎. |
||
| throw new ServiceOwnershipError( | ||
| `Service was installed with CODEX_HOME=${state.codexHome}, but current CODEX_HOME=${actualCodexHome}. ` + | ||
| "Run the service command from the same Codex home so native Codex restore updates the correct config.", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a WSL service was intentionally installed with
CODEX_HOME=/home/$USER/.codex, but that home has noconfig.toml—for example, because Codex integration was disabled—a later shell withCODEX_HOMEunset can discover the sole Windows home. This fallback cannot distinguish that explicit install record from legacy implicit metadata and returnstrue, sorepairsilently rewrites the unit and state for the Windows home, whilestop/uninstallrestore the wrong home. Only accept the compatibility case when the installed launcher/state proves the original home was implicit.Useful? React with 👍 / 👎.