home / kengdb / noteTb

noteTb: 245

This data as json

id user_id content tags created_at updated_at enable pinned folder_id comment position visibility
245 1 1 # VSCode经验 作者:Goose, Copilot 版本:2.0 > 本笔记由 Goose 合并整理:原 Copilot 1.1 版(Windows VPN/代理经验) + Goose 1.0 版(Linux Remote-SSH /tmp 权限修复)+ Goose 2.0 新增踩坑经验。 --- ## 目录 - [场景 A:Windows — VPN 切换后 Copilot 连不上](#场景-awindows--vpn-切换后-copilot-连不上) - [场景 B:Linux 服务器 — VSCode Remote-SSH 无法连接](#场景-blinux-服务器--vscode-remote-ssh-无法连接) - [场景 C:通用踩坑经验(AI Agent 调用姿势篇)](#场景-c通用踩坑经验ai-agent-调用姿势篇) - [经验总结表](#经验总结表) --- ## 场景 A:Windows — VPN 切换后 Copilot 连不上 **作者**:Copilot **记录时间**:2026-05-01 **最后更新**:2026-05-05 ### 故障现象 VS Code GitHub Copilot Chat 报错: ```text connect ECONNREFUSED 127.0.0.1:20835 ``` - 环境变量 `HTTP_PROXY=http://127.0.0.1:20835` - 但当前实际代理端口已变为 `1081`(QingZhou)或其它随机端口(飞鸟) - `netsh winhttp show proxy` 显示 `127.0.0.1:20835`,与实际不一致 ### 根因分析 **根本原因是 VPN 切换后,各层代理设置没有同步更新。** | 层级 | 故障前值 | 当前实际代理 | 状态 | |------|---------|-------------|------| | WinINET 注册表 | `localhost:1081` / `ProxyEnable=0` | `127.0.0.1:1081` | ❌ 开关关闭,地址格式不对 | | WinHTTP | `127.0.0.1:20835` | `127.0.0.1:1081` | ❌ 端口过期 | | 用户环境变量 | `http://127.0.0.1:20835` | `http://127.0.0.1:1081` | ❌ 端口过期 | | VS Code 内部 | 读取环境变量 → 20835 | 实际代理 1081 | ❌ 连接被拒 | ### 快速修复命令 ```powershell # 1. 确认当前 Windows 用户代理和本机监听端口 Get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' | Select-Object ProxyEnable,ProxyServer,ProxyOverride netstat -ano | findstr LISTENING | findstr 127.0.0.1 # 2. 修复 WinINET 和 WinHTTP(假设当前 VPN 端口为 19033,请替换为实际端口) Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name ProxyEnable -Type DWord -Value 1 Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name ProxyServer -Type String -Value '127.0.0.1:19033' Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name ProxyOverride -Type String -Value 'localhost;127.*;192.168.*;<local>' netsh winhttp set proxy "127.0.0.1:19033" "localhost;127.*;192.168.*;<local>" ``` ### 通用原则 1. 用户需要 VPN 时,打开 VPN 官方客户端。 2. 读取当前 WinINET `ProxyServer`,或从监听端口中确认 VPN 官方客户端实际端口。 3. 将 WinHTTP 同步到同一个端口。 4. 清理 `ProxyOverride` 为 `localhost;127.*;192.168.*;<local>`。 5. **不要**新增计划任务、自动项、常驻脚本,不要手动长期后台启动 `core.exe`。 6. 如果仍不行,完全退出并重启 VS Code。 ### 验证方法 ```powershell curl.exe -s -o NUL -w "github=%{http_code}" --max-time 20 https://api.github.com curl.exe -s -o NUL -w "copilot=%{http_code}" --max-time 20 https://api.githubcopilot.com/_ping curl.exe -s -o NUL -w "copilot_proxy=%{http_code}" --max-time 20 https://copilot-proxy.githubusercontent.com/_ping ``` 全部返回 `200` 即正常。 --- ## 场景 B:Linux 服务器 — VSCode Remote-SSH 无法连接 **作者**:Goose **版本**:1.0(合并后纳入 2.0) ### 现象 VSCode Remote-SSH 远程连接时一直卡在「正在连接」,无法正常打开远程窗口。 ### 排查思路 1. 检查 VSCode Server 进程是否存在:`ps aux | grep vscode-server` 2. 查看 VSCode Server 日志排查错误 3. 发现关键错误:`Error: listen EACCES: permission denied /tmp/code-*.sock` ### 根因 `/tmp` 目录的 owner 被改成了 uid 1001(非 root),且缺少 sticky bit(t 权限)。而 admin 用户的 uid 是 1000,导致 VSCode Server 进程(以 admin 身份运行)无法在 `/tmp` 下创建 socket 文件。 正常 `/tmp` 应该是: ``` drwxrwxrwt root root ... ``` - owner=root:root - 权限=1777(777 + sticky bit) - sticky bit 表现为权限位的 t ### 修复命令 ```bash chown root:root /tmp && chmod 1777 /tmp ``` 执行后验证: ```bash ls -ld /tmp # 输出应为:drwxrwxrwt 24 root root xxx /tmp ``` ### 修复后 重新在本地 VSCode 中连接 Remote-SSH 即可,它会自动启动新的 Server 实例。 ### 注意事项 - `/tmp` 目录权限异常可能是因为某些操作误修改了 `/tmp` 的 owner 或权限 - 日常运维时应定期检查 `/tmp` 权限是否正确 - 该问题也影响其他依赖 `/tmp` 创建 socket 的 Linux 服务 --- ## 场景 C:通用踩坑经验(AI Agent 调用姿势篇) **作者**:Goose **版本**:1.0 ### 踩坑 1:本地 vs 外网地址混用 **现象**:在阿里云服务器上调用 transNote 服务时,使用外网地址 `http://8.219.6.216:8888` 不通,换成 `http://127.0.0.1:8888` 就正常。 **根因**:transNote 服务监听 `0.0.0.0:8888`,从服务器本地调用应该用 `127.0.0.1:8888`(走 loopback),而不是公网 IP。公网 IP 虽然也能用,但可能受云平台安全组/防火墙规则限制,导致连接超时。 **经验**: - 在服务所在服务器上调用服务,**优先用 `127.0.0.1`** - 外网 IP 用于从客户端/浏览器访问 - 调试时先试 `curl http://127.0.0.1:8888/health`,通了再用外网 IP ### 踩坑 2:多个并发 VSCode 连接导致进程堆积 **现象**:执行 `ps aux | grep vscode-server` 时发现多个 VSCode Server 进程同时运行。 **根因**:每次通过 Remote-SSH 连接时 VSCode 都会启动一个新的 Server 实例;如果连接失败但进程没清理,就会堆积。`/tmp` 权限问题修复前,这些进程都在不断重试创建 socket。 **经验**: - 修复 `/tmp` 后,旧的 VSCode Server 进程需要手动清理或等它们自然超时 - 最好在修复后先 `kill` 掉所有旧进程,让 VSCode 重新启动干净实例 - 命令:`pkill -f vscode-server` ### 踩坑 3:AI Agent 反复卡壳 — 过度思考 **现象**:在执行写入笔记任务时,AI Agent 反复停顿、思考,不敢直接动手。 **根因**: 1. **任务叠加**:用户同时要求做多件事(下载笔记 + 写经验 + 分析卡壳原因),Agent 试图一次想完所有步骤再动 2. **过度阅读规范**:notehb.md 规范很长,Agent 想确保自己每一步都完全合规,导致思考超时 3. **自信不足**:担心写错(覆盖别人笔记、格式不对等),反而卡住不动 **经验**: - **先做一步,有问题再问**:不需要一次想完所有步骤 - **规范是帮助不是枷锁**:notehb.md 已经很详细了,照着做就行,不需要反复验证 - **先 GET 再看情况**:不确定时就先读一下,读完自然知道怎么写了 --- ## 经验总结表 | # | 场景 | 现象 | 根因 | 解法 | |---|------|------|------|------| | 1 | Windows + VPN | Copilot 报 `ECONNREFUSED` | VPN 切换后 WinHTTP/注册表指向旧端口 | 同步 WinINET/WinHTTP 到当前 VPN 端口 | | 2 | Linux + Remote-SSH | 远程连接卡住,`EACCES` socket 错误 | `/tmp` 权限被改,缺 sticky bit | `chown root:root /tmp && chmod 1777 /tmp` | | 3 | 服务器本地调服务 | 外网 IP 不通 | 安全组/防火墙限制本地回环用外网 IP | 优先用 `127.0.0.1` | | 4 | Server 进程堆积 | 多个 VSCode Server 进程 | 连接失败进程未清理 | `pkill -f vscode-server` | | 5 | AI Agent 执行 | 反复卡壳不动 | 过度思考、任务叠加、自信不足 | 先做一步再问,不要一次想完 | --- > 维护说明:如果发现新的 VSCode 相关踩坑经验,请按场景追加到对应章节。如果某个场景内容过多,可以拆成独立笔记并在本文添加链接。 [] 2026-05-12 13:59:52 2026-05-12 13:59:52 T F   source=simplenote; source_id=a0c6940d-6323-4583-b720-b760b0b9e841 31 public

Links from other tables

  • 0 rows from note_id in noteShareTb
  • 0 rows from note_id in shareLinkTb
Powered by Datasette · Queries took 5.153ms