emrg: build-release 二十一次修复 — smoke Windows daemon HOME 同步 + 启动诊断(rant #13) - #389
Merged
Conversation
…13) 根因:Windows 分支经 cmd 启动 emrgd.cmd → 原生 python.exe 的 Path.home() 读 USERPROFILE(真实用户目录),不认 Git Bash 的 $HOME(mktemp 隔离目录)。 daemon 去真实目录找 config.toml → FileNotFoundError 崩溃 → 不写 port 文件, smoke 在隔离目录轮询 15s 无果。 修复: - Windows 下同步 USERPROFILE/HOMEDRIVE/HOMEPATH 到隔离 $HOME(cygpath -w) - daemon 启动输出保留到 emrgd-debug.log(原 /dev/null 丢弃),失败时 cat 诊断 traceback,避免下次盲猜 daemon did not write port file
argszero
commented
Aug 4, 2026
argszero
left a comment
Owner
Author
There was a problem hiding this comment.
✅ LGTM — cycle 20260805-0094
修复定位准确:Windows 下 cmd 启动的原生 python.exe 的 Path.home() 走 USERPROFILE
而非 Git Bash 的 HOME(mktemp 隔离目录失效)→ daemon 读不到隔离 config 崩溃。
USERPROFILE/HOMEDRIVE/HOMEPATH 三变量同步 + cygpath -w 转换正确;debug 日志保留
(emrgd-debug.log)避免后续盲猜。bash -n OK;pytest 464 passed。
argszero
commented
Aug 4, 2026
argszero
left a comment
Owner
Author
There was a problem hiding this comment.
✅ LGTM — cycle 20260805-0095
第二次复核:diff 稳定(R114 HOME 三变量同步 + emrgd-debug.log 诊断)。逻辑核对:
- USERPROFILE=$(cygpath -w
$HOME) → HOMEDRIVE=$ {USERPROFILE:0:2} → HOMEPATH=${USERPROFILE:2},Python Path.home() 在 Windows 的解析链完整覆盖 - 两个 daemon 启动点(step 2 + step 5)均保留输出,port 轮询失败 cat 日志 → 下轮实跑可见真实 traceback
- bash -n OK;pytest 464 passed(cycle 0094 验证)
2 个连续 LGTM(0094/0095),无 ❌。
argszero
commented
Aug 4, 2026
argszero
left a comment
Owner
Author
There was a problem hiding this comment.
✅ LGTM — cycle 20260805-0096
第三次复核:diff 稳定(+18/-5,R114 HOME 三变量同步 + emrgd-debug.log 诊断)。
3 个连续 LGTM(0094/0095/0096),中间无 ❌,满足合并条件。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
根因
run 21(f7143e3)Windows smoke 3 项失败(8 pass 3 fail),全部源于同一根因:
daemon 未写 port 文件。
emrg --version(bash 脚本 → 继承 Git Bash$HOME)通过,但
emrgd.cmd(经cmd //c start /b启动的原生 python.exe)的Path.home()在Windows 读
USERPROFILE/HOMEDRIVE/HOMEPATH—— 指向真实用户目录C:\Users\runneradmin,而非 smoke 的隔离HOME=$(mktemp -d)。后果:daemon 去
C:\Users\runneradmin\.emrg\config.toml找配置(smoke 只写了隔离目录的 config)→
FileNotFoundError→ 崩溃退出 → 不写 port 文件。smoke 在隔离目录轮询 15s →
✗ daemon did not write port file(连带 server stop / rant 失败)。修复
export USERPROFILE="$(cygpath -w "$HOME")"+HOMEDRIVE/HOMEPATH → python
Path.home()与 smoke 隔离目录一致/dev/null,保留到emrgd-debug.log;port 轮询失败时 cat 该日志 +
emrgd.logtail,后续失败可直接看到 traceback验证
bash -n packaging/smoke-test.shOKuv run pytest tests/ -q= 464 passedCLI 无法本机跑完整 smoke(pkill 会杀宿主 daemon),冒烟依赖 CI 实跑验证。