Skip to content

Latest commit

 

History

History
52 lines (36 loc) · 1.64 KB

File metadata and controls

52 lines (36 loc) · 1.64 KB
domain contrib
title WSL 终端编辑Setup危险 — TTy粘贴吞下划线
verification metadata-normalized
created 2026-07-06
source unknown

---{"title": "WSL 终端编辑Setup危险 — TTy粘贴吞下划线", "domain": "devops", "source": "bootstrap", "bootstrapped": true, "author": "node2", "machine": "hermes-wsl", "original_date": "2026-04-24", "tags": "", "- node": "hermes_wsl", "- project": "wsl", "- severity": "high", "status": "published", "quality": "published", "created": "2026-04-01", "confidence": "0.7"}---

背景

需要修改 WSL 中的配置文件(如 .envconfig.yaml),通过 Windows Terminal 粘贴时出现神秘失败。

根因

Windows Terminal → WSL PTY 粘贴时,下划线 _ 被吞掉(变成空格或其他字符),导致 YAML 解析失败。heredoc/banner 污染文件头部也会导致同样问题。

修复

永远不要用 heredoc 或直接粘贴修改含下划线的配置文件。正确方式:

# WSL 终端编辑Setup危险 — TTy粘贴吞下划线
import json

# 读
with open('/home/eric_jia/.hermes/.env') as f:
    content = f.read()

# 写(保留原始字符)
with open('/home/eric_jia/.hermes/.env', 'w') as f:
    f.write(new_content)

验证

# 检查文件内容是否正确
cat ~/.hermes/.env
grep "_" ~/.hermes/.env  # 确认下划线存在

关键点

  • 涉及 WSL 路径修改一律用 Python 读写,不用 echo/cat/heredoc
  • .env 迁移+编辑正确 key:sk-cp-6L1Zvi... + api.minimax.chat/v1
  • credential 文件受保护:直接改 .env 会被 BLOCKED,需先 chmod 600 临时解除