fix(codex): write config to ~/.codex/ not %APPDATA%\codex\
Codex CLI reads config from %USERPROFILE%\.codex\config.toml but PowerShell fallback was writing to %APPDATA%\codex\config.toml. Old broken config remained in ~/.codex/ causing TOML parse errors. - Fix config path: $env:APPDATA\codex → $env:USERPROFILE\.codex - Add cleanup step to remove broken config before patching - Remove old config before writing new one Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -148,6 +148,19 @@ if ($currentVersion -eq $latestVersion) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ---- Clean up broken config from previous runs ----
|
||||||
|
# Codex stores config in ~/.codex/ (= %USERPROFILE%\.codex\)
|
||||||
|
$codexConfigDir = "$env:USERPROFILE\.codex"
|
||||||
|
$codexConfigFile = "$codexConfigDir\config.toml"
|
||||||
|
if (Test-Path $codexConfigFile) {
|
||||||
|
# Check if existing config is broken (Codex writes bad TOML with dotted model keys)
|
||||||
|
$existingContent = Get-Content $codexConfigFile -Raw -ErrorAction SilentlyContinue
|
||||||
|
if ($existingContent -match "gpt-5\s*=" -and $existingContent -match "\{.*:") {
|
||||||
|
Write-Host " Removing broken config.toml..." -ForegroundColor Yellow
|
||||||
|
Remove-Item $codexConfigFile -Force -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# ---- Apply patches ----
|
# ---- Apply patches ----
|
||||||
|
|
||||||
if ($pyCmd) {
|
if ($pyCmd) {
|
||||||
@@ -192,10 +205,16 @@ if (-not $pyCmd) {
|
|||||||
# PowerShell fallback — generate config.toml directly
|
# PowerShell fallback — generate config.toml directly
|
||||||
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
|
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
|
||||||
|
|
||||||
$configDir = "$env:APPDATA\codex"
|
# Codex reads config from ~/.codex/ (NOT %APPDATA%\codex\)
|
||||||
|
$configDir = "$env:USERPROFILE\.codex"
|
||||||
New-Item -ItemType Directory -Force -Path $configDir | Out-Null
|
New-Item -ItemType Directory -Force -Path $configDir | Out-Null
|
||||||
$configToml = Join-Path $configDir "config.toml"
|
$configToml = Join-Path $configDir "config.toml"
|
||||||
|
|
||||||
|
# Remove old broken config if exists
|
||||||
|
if (Test-Path $configToml) {
|
||||||
|
Remove-Item $configToml -Force -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
|
||||||
$tomlContent = @"
|
$tomlContent = @"
|
||||||
model = "gpt-5.4"
|
model = "gpt-5.4"
|
||||||
model_reasoning_effort = "high"
|
model_reasoning_effort = "high"
|
||||||
@@ -224,12 +243,6 @@ wire_api = "responses"
|
|||||||
[System.IO.File]::WriteAllText($configToml, $tomlContent)
|
[System.IO.File]::WriteAllText($configToml, $tomlContent)
|
||||||
Write-Host " config.toml created: $configToml" -ForegroundColor Green
|
Write-Host " config.toml created: $configToml" -ForegroundColor Green
|
||||||
|
|
||||||
# Create auth token
|
|
||||||
$authDir = "$env:APPDATA\codex"
|
|
||||||
$authFile = Join-Path $authDir ".codex_api_key"
|
|
||||||
[System.IO.File]::WriteAllText($authFile, "ClauderAPI")
|
|
||||||
Write-Host " Auth token set" -ForegroundColor Green
|
|
||||||
|
|
||||||
# Set env vars via setx
|
# Set env vars via setx
|
||||||
& setx OPENAI_API_KEY "ClauderAPI" 2>$null | Out-Null
|
& setx OPENAI_API_KEY "ClauderAPI" 2>$null | Out-Null
|
||||||
& setx OPENAI_BASE_URL "https://ai.37-187-136-86.sslip.io/v1" 2>$null | Out-Null
|
& setx OPENAI_BASE_URL "https://ai.37-187-136-86.sslip.io/v1" 2>$null | Out-Null
|
||||||
|
|||||||
@@ -132,9 +132,12 @@ if ($pyCmd) {
|
|||||||
|
|
||||||
if (-not $pyCmd) {
|
if (-not $pyCmd) {
|
||||||
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
|
Write-Host " Applying patches (PowerShell)..." -ForegroundColor Cyan
|
||||||
$configDir = "$env:APPDATA\codex"
|
# Codex reads config from ~/.codex/ (NOT %APPDATA%\codex\)
|
||||||
|
$configDir = "$env:USERPROFILE\.codex"
|
||||||
New-Item -ItemType Directory -Force -Path $configDir | Out-Null
|
New-Item -ItemType Directory -Force -Path $configDir | Out-Null
|
||||||
$configToml = Join-Path $configDir "config.toml"
|
$configToml = Join-Path $configDir "config.toml"
|
||||||
|
# Remove old broken config
|
||||||
|
if (Test-Path $configToml) { Remove-Item $configToml -Force -ErrorAction SilentlyContinue }
|
||||||
$tomlContent = @"
|
$tomlContent = @"
|
||||||
model = "gpt-5.4"
|
model = "gpt-5.4"
|
||||||
model_reasoning_effort = "high"
|
model_reasoning_effort = "high"
|
||||||
|
|||||||
Reference in New Issue
Block a user