fix: isolate docs i18n codex home

This commit is contained in:
Peter Steinberger
2026-04-28 04:58:47 +01:00
parent da773cf074
commit 4d69f81a4e
2 changed files with 11 additions and 0 deletions

View File

@@ -179,6 +179,12 @@ func runCodexExecPrompt(ctx context.Context, req codexPromptRequest) (string, er
_ = outputFile.Close()
defer os.Remove(outputPath)
codexHome, err := os.MkdirTemp("", "openclaw-docs-i18n-codex-home-*")
if err != nil {
return "", err
}
defer os.RemoveAll(codexHome)
args := []string{
"exec",
"--model", req.Model,
@@ -191,6 +197,7 @@ func runCodexExecPrompt(ctx context.Context, req codexPromptRequest) (string, er
}
command := exec.CommandContext(ctx, docsCodexExecutable(), args...)
command.Stdin = strings.NewReader(buildCodexTranslationPrompt(req.SystemPrompt, req.Message))
command.Env = append(os.Environ(), "CODEX_HOME="+codexHome)
var stdout bytes.Buffer
var stderr bytes.Buffer
command.Stdout = &stdout

View File

@@ -149,6 +149,10 @@ while [ "$#" -gt 0 ]; do
shift || true
done
cat >/dev/null
if [ -z "${CODEX_HOME:-}" ]; then
echo "missing CODEX_HOME" >&2
exit 1
fi
printf 'translated from codex\n' > "$out"
`), 0o755); err != nil {
t.Fatalf("write fake codex: %v", err)