Skip to content

emrg: build-release 二十一次修复 — smoke Windows daemon HOME 同步 + 启动诊断(rant #13) - #389

Merged
argszero merged 1 commit into
masterfrom
build-release-fixes-21
Aug 4, 2026
Merged

emrg: build-release 二十一次修复 — smoke Windows daemon HOME 同步 + 启动诊断(rant #13)#389
argszero merged 1 commit into
masterfrom
build-release-fixes-21

Conversation

@argszero

@argszero argszero commented Aug 4, 2026

Copy link
Copy Markdown
Owner

根因

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 失败)。

修复

  1. HOME 同步:Windows 分支 export USERPROFILE="$(cygpath -w "$HOME")" +
    HOMEDRIVE/HOMEPATH → python Path.home() 与 smoke 隔离目录一致
  2. 启动诊断:daemon 输出不再丢 /dev/null,保留到 emrgd-debug.log
    port 轮询失败时 cat 该日志 + emrgd.log tail,后续失败可直接看到 traceback

验证

  • bash -n packaging/smoke-test.sh OK
  • uv run pytest tests/ -q = 464 passed
  • 下次实跑预期:Windows daemon 能读到隔离 config → 写 port → auth+pong 通过

CLI 无法本机跑完整 smoke(pkill 会杀宿主 daemon),冒烟依赖 CI 实跑验证。

…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 argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 20260805-0096

第三次复核:diff 稳定(+18/-5,R114 HOME 三变量同步 + emrgd-debug.log 诊断)。
3 个连续 LGTM(0094/0095/0096),中间无 ❌,满足合并条件。

@argszero
argszero merged commit 1c8b256 into master Aug 4, 2026
1 check passed
@argszero
argszero deleted the build-release-fixes-21 branch August 5, 2026 06:18
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