Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Codex Bugs Fix Solution

本公开项目涵盖以下内容:

  • 因 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.sqlite file that should not have done.

OpenAI 你是往 Windows 里塞了一组 bug,bug 里做了个 Codex 吗 [捂脸笑]

Content

  1. 【脚本使用前必读】脚本使用说明 | Scripts Instruction
  2. 【如果还有乱码请阅读】PowerShell 代码页设置 | PowerShell Code Page Settings

License

MIT License – Free to use, modify, and distribute. Use at your own risk.


脚本使用说明

简体中文 | English

1. 拦截 logs_2.sqlite 的高频非 ERROR 日志写入

此处的拦截操作会保留 ERROR 级日志写入,仅丢弃其他级别的日志,可在减少无意义写入的同时保留排障所需的错误信息

  • 方式A:在 python 中运行 ./sqlite_fix/codex_log_repair.py,根据提示选择对 logs_2.sqlite 文件的拦截策略
  • 方式B:从 Release 发布页下载 codex-log-repair.exe 后直接运行(运行 EXE 程序可能引起杀毒软件误报,忽略即可)

2. 清理无效、未知的 SID,夺回文件/文件夹的用户所属权

  • 这个 bug 截至 2026.07.22 只在 Windows 系统上存在,其他系统或模拟器无需完成本节操作
  • 在管理员身份下打开 PowerShell,运行 ./sid_fix 中的 *.ps1 脚本
脚本名称 功能
Check-Owner.ps1 检查文件、文件夹的所属用户
Check-Unknown-SID.ps1 检查文件、文件夹是否存在已失效的、未知的 SID
Repaire-And-Clean.ps1 修复文件、文件夹所属用户权限,清理无效 SID

3. 关于输出文本

  • 如发现输出内容出现乱码,大概率是因为编码格式有误,请将 *.ps1 脚本设为 UTF-8 BOM,python 脚本设为 UTF-8

Scripts Instruction

简体中文 | English

1. Intercept high-volume non-ERROR writes to logs_2.sqlite

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.py in python, and choose the interception strategy for the logs_2.sqlite file according to the prompt
  • Method B: Download codex-log-repair.exe from the Release page and run it directly (Running EXE program may cause false positives of antivirus software, so just ignore it)

2. Clean up the invalid and unknown SID, reclaim the user ownership of files / folders

  • 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 *.ps1 script 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!

3. About Output Text

  • 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 *.ps1 script to UTF-8 BOM and python script to UTF-8.

PowerShell 代码页设置

简体中文 | English

需求背景

  • 在中文环境下,PowerShell 默认代码页为 GBK,这会导致运行 UTF-8 的脚本出现乱码
  • 同时,在深度使用 Codex 等 AGENT CLI 工具的过程中,若因编码格式不统一导致修改文本变为乱码,更得不偿失

解决方案

  1. 可以先右键 PowerShell 左上角图标,进入“属性”,即可在弹出对话框中查看当前的代码页是否为 65001(UTF-8)

代码页

  1. 若代码页不为 UTF-8,请在 PowerShell 中输入 $PROFILE 确认 profile 文件所在路径
  2. 然后你可能会看到一个叫做 Microsoft.PowerShell_profile.ps1 的文件所在路径,也可能没有
  3. 若文件不存在,先创建目录和文件(如果第三步已经有这个文件了,就跳过此步骤):
# 没有 profile 文件的话,执行下面的命令
New-Item -ItemType Directory -Force -Path (Splite-Path $PROFILE)
New-Item -ItemType File -Force -Path $PROFILE
  1. 然后用记事本编辑 profile 文件,向其中添加如下内容:
[System.Console]::OutputEncoding = [System.Text.Encoding]::UTF8
[System.Console]::InputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8
  1. 保存后,重新启动 PowerShell 即可,此时属性中的代码页应已变为 65001

PowerShell Code Page Settings

简体中文 | English

Background

  • 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.

Solution

  1. 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).

Code Page

  1. If the code page is not UTF-8, enter $PROFILE in PowerShell to confirm the path to the profile file.
  2. You may then see the path to a file named Microsoft.PowerShell_profile.ps1, or you may not.
  3. 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
  1. 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
  1. Restart PowerShell after saving. The code page in the properties should now be set to 65001.

About

修复 Codex 沙箱模式的 Bug:批量检查并修复Windows文件/文件夹的所有者,清理未知用户和权限,拦截本不应该有的巨量写入请求。 | Fix bugs in Codex sandbox mode: check and repair the owners of Windows files/folders in batches, clean up unknown users and permissions, and intercept a huge amount of write requests that should not be there.

Topics

Resources

Stars

Watchers

Forks

Releases

Contributors

Languages