Skip to content

Conversation

@blackrion
Copy link

问题描述

在 Windows 中文环境下,WeztermBackend 和 Iterm2Backend 的 subprocess 调用会因为默认使用 GBK 编码而导致解码失败:

UnicodeDecodeError: 'gbk' codec can't decode byte

这会导致:

  • ccb status 无法正常检查终端状态
  • is_alive() 方法失败
  • 创建终端窗格时出错

解决方案

为所有 subprocess.run 调用添加 encoding='utf-8'errors='replace' 参数,确保在 Windows 环境下使用 UTF-8 编码。

影响的方法

  • WeztermBackend.is_alive() - lib/terminal.py:316
  • WeztermBackend.create_pane() - lib/terminal.py:371
  • Iterm2Backend.is_alive() - lib/terminal.py:210
  • Iterm2Backend.create_pane() - lib/terminal.py:237

测试环境

  • ✅ Windows 11 with Chinese locale
  • ✅ WezTerm backend
  • ✅ 修复后 ccb status 和 session 管理正常工作

相关提交

这个修复补充了之前的 Windows 兼容性改进工作,与以下提交相关:

  • c35c096 fix(cask-w,gask-w): move setup_windows_encoding to module level
  • 6d9da2f fix(install.ps1): add UTF-8 BOM and encoding setup for PS5.1 compatibility
  • f8cf9cc fix(windows): add Windows compatibility fixes

修复 WeztermBackend 和 Iterm2Backend 在 Windows 环境下的编码问题:
- 为所有 subprocess.run 调用添加 encoding='utf-8' 和 errors='replace' 参数
- 解决 UnicodeDecodeError: 'gbk' codec can't decode byte 错误
- 确保 WezTerm 和 iTerm2 的状态检查在 Windows 中文环境下正常工作

受影响的方法:
- WeztermBackend.is_alive()
- Iterm2Backend.is_alive()
- Iterm2Backend.create_pane()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant