Skip to content

Commit 9cdffa8

Browse files
committed
fix
1 parent 206739f commit 9cdffa8

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

cmd/onecli/run.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,31 @@ func rewriteProxyEnvHosts(env map[string]string, localHost string) {
393393
}
394394
}
395395

396+
// containerHomeEnv maps env vars that the server returns as container-internal
397+
// home paths to their home-relative local equivalent. A local agent process
398+
// needs host paths (where onecli writes the agent's auth stub and config), not
399+
// the Docker sandbox paths the server returns (e.g. CODEX_HOME=/home/node/.codex).
400+
var containerHomeEnv = map[string]string{
401+
"CODEX_HOME": ".codex",
402+
}
403+
404+
// rewriteContainerHomeEnv replaces container-internal home paths in the server
405+
// env with the local equivalent under home. Codex aborts when CODEX_HOME points
406+
// at a path that does not exist on the host, so the container path must be
407+
// translated before exec. Mutating cfg.Env (rather than only appending later)
408+
// also ensures buildChildEnv strips any stale inherited value, so the container
409+
// path can't shadow the rewritten one.
410+
func rewriteContainerHomeEnv(env map[string]string, home string) {
411+
if home == "" {
412+
return
413+
}
414+
for k, rel := range containerHomeEnv {
415+
if _, ok := env[k]; ok {
416+
env[k] = filepath.Join(home, rel)
417+
}
418+
}
419+
}
420+
396421
// isLoopbackHost reports whether h is a loopback host a Docker container cannot
397422
// reach directly (so it must go through host.docker.internal instead).
398423
func isLoopbackHost(h string) bool {

0 commit comments

Comments
 (0)