本公开项目涵盖以下内容:
- 因 Codex 造成 ACL 污染,需清理的无效的、未知的 SID
- 将文件和文件夹的权限恢复给本应所属的用户
- 拦截本不该出现的、对
log_2.sqlite文件的巨量写入请求
This public project covers the following contents:
- Invalid and unknown SID that needs to be cleaned up due to ACL pollution caused by Codex.
- Restore the user to whom the permissions of files and folders belong.
- Intercept a huge amount of write requests to the
log_2.sqlitefile that should not have done.
OpenAI 你是往 Windows 里塞了一组 bug,bug 里做了个 Codex 吗 [捂脸笑]
- 【脚本使用前必读】脚本使用说明 | Scripts Instruction
- 【如果还有乱码请阅读】PowerShell 代码页设置 | PowerShell Code Page Settings
MIT License – Free to use, modify, and distribute. Use at your own risk.
简体中文 | English
此处的拦截操作会保留 ERROR 级日志写入,仅丢弃其他级别的日志,可在减少无意义写入的同时保留排障所需的错误信息
- 方式A:在 python 中运行
./sqlite_fix/codex_log_repair.py,根据提示选择对logs_2.sqlite文件的拦截策略 - 方式B:从 Release 发布页下载
codex-log-repair.exe后直接运行(运行 EXE 程序可能引起杀毒软件误报,忽略即可)
- 这个 bug 截至 2026.07.22 只在 Windows 系统上存在,其他系统或模拟器无需完成本节操作
- 在管理员身份下打开 PowerShell,运行
./sid_fix中的*.ps1脚本
| 脚本名称 | 功能 |
|---|---|
Check-Owner.ps1 |
检查文件、文件夹的所属用户 |
Check-Unknown-SID.ps1 |
检查文件、文件夹是否存在已失效的、未知的 SID |
Repaire-And-Clean.ps1 |
修复文件、文件夹所属用户权限,清理无效 SID |
- 使用方法详见 how2use-SIDFix,请务必阅读操作指南!
- 如发现输出内容出现乱码,大概率是因为编码格式有误,请将
*.ps1脚本设为UTF-8 BOM,python 脚本设为UTF-8
简体中文 | English
This interception keeps ERROR level logs available for troubleshooting and drops other log levels to reduce unnecessary writes.
- Method A: Run
./sqlite_fix/codex_log_repair.pyin python, and choose the interception strategy for thelogs_2.sqlitefile according to the prompt - Method B: Download
codex-log-repair.exefrom the Release page and run it directly (Running EXE program may cause false positives of antivirus software, so just ignore it)
- As of July 22, 2026, this bug only affects Windows systems; users of other operating systems or emulators do not need to follow the steps in this section.
- Open PowerShell as an administrator and run the
*.ps1script in./sid_fix
| Script Name | Function |
|---|---|
Check-Owner.ps1 |
Check the owner of files and folders |
Check-Unknown-SID.ps1 |
Check files and folders for invalid and unknown SID |
Repaire-And-Clean.ps1 |
Repair the user rights of files and folders, and clean up invalid SID |
- See how2use-SIDFix for detailed usage instructions. Please be sure to read the operation instruction!
- The output text of all scripts is simplified Chinese, and you can use AI to modify it into English or your native language.
- If the output after running is garbled, it must be caused by the wrong coding format. Please set
*.ps1script toUTF-8 BOMand python script toUTF-8.
简体中文 | English
- 在中文环境下,PowerShell 默认代码页为 GBK,这会导致运行 UTF-8 的脚本出现乱码
- 同时,在深度使用 Codex 等 AGENT CLI 工具的过程中,若因编码格式不统一导致修改文本变为乱码,更得不偿失
- 可以先右键 PowerShell 左上角图标,进入“属性”,即可在弹出对话框中查看当前的代码页是否为 65001(UTF-8)
- 若代码页不为 UTF-8,请在 PowerShell 中输入
$PROFILE确认 profile 文件所在路径 - 然后你可能会看到一个叫做
Microsoft.PowerShell_profile.ps1的文件所在路径,也可能没有 - 若文件不存在,先创建目录和文件(如果第三步已经有这个文件了,就跳过此步骤):
# 没有 profile 文件的话,执行下面的命令
New-Item -ItemType Directory -Force -Path (Splite-Path $PROFILE)
New-Item -ItemType File -Force -Path $PROFILE- 然后用记事本编辑 profile 文件,向其中添加如下内容:
[System.Console]::OutputEncoding = [System.Text.Encoding]::UTF8
[System.Console]::InputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8- 保存后,重新启动 PowerShell 即可,此时属性中的代码页应已变为 65001
简体中文 | English
- In a Chinese-language environment, PowerShell’s default code page is GBK, which can cause UTF-8 scripts to display garbled characters.
- Furthermore, when using AGENT CLI tools such as Codex extensively, if text modifications result in garbled characters due to inconsistent encoding formats, the drawbacks far outweigh the benefits.
- First, right-click the PowerShell icon in the upper-left corner. Go to “Properties,” and then you can view the current code page in the dialog box, confirming whether it is 65001 (UTF-8).
- If the code page is not UTF-8, enter
$PROFILEin PowerShell to confirm the path to the profile file. - You may then see the path to a file named
Microsoft.PowerShell_profile.ps1, or you may not. - If the file does not exist, create the directory and the file first (if this file already exists from step 3, skip this step):
# Execute the following command if there is no profile file
New-Item -ItemType Directory -Force -Path (Splite-Path $PROFILE)
New-Item -ItemType File -Force -Path $PROFILE- Next, open the profile file in Notepad and add the following content inside:
[System.Console]::OutputEncoding = [System.Text.Encoding]::UTF8
[System.Console]::InputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8- Restart PowerShell after saving. The code page in the properties should now be set to 65001.
