Skip to content

[temp][DO NOT MERGE] Windows no-git default-user flow repro CI#114

Open
Sunrisepeak wants to merge 2 commits into
mainfrom
test/windows-no-git-user-flow
Open

[temp][DO NOT MERGE] Windows no-git default-user flow repro CI#114
Sunrisepeak wants to merge 2 commits into
mainfrom
test/windows-no-git-user-flow

Conversation

@Sunrisepeak
Copy link
Copy Markdown
Member

目的(临时 PR,勿合并)

复现并验证 Windows 上默认用户(未安装系统 git)的失败链路:

xlings install mcppmcpp newmcpp build 报错、mcpp self init --force 报错,核心疑似 mcpp registry 沙箱没有包索引,且 xlings 报"没有 git",但用户终端 git --version 正常。

假设的根因链(代码分析得出)

  1. Windows 下用户没有系统 git 时,xlings 自动安装 xim:git(PortableGit),并在 ~/.xlings/subos/current/bin 生成 xvm shim(即改名为 git.exe 的 xlings 二进制),shim 运行时按 XLINGS_HOME 查版本数据库 → 用户终端里 git --version 正常 ✅
  2. mcpp 在 Windows 上把 XLINGS_HOME 进程内重定向到 ~/.mcpp/registry(src/xlings.cppm build_command_prefix / ensure_init)→ 子进程里 PATH 上的 git shim 继承了被重定向的 XLINGS_HOME,在 registry 沙箱版本库中查不到 git → xlings: 'git' is not installed,compact::git 判定 git 不可用 ❌
  3. xlings 索引同步只有 git 一条路(src/core/xim/repo.cppm:"git is required to update package index",无 HTTP 降级);git 自举 xlings install xim:git 又需要索引 → 鸡生蛋死锁(XLINGS_COMPACT_GIT_BOOTSTRAP 递归防护直接报错)
  4. registry 沙箱始终没有索引 → ninja/toolchain 无法安装 → mcpp build 失败;mcpp self init --force 在 check_base_init 报 init incomplete: ninja missing from sandbox

本 CI 验证点

  • Stage 2b:装完 mcpp 后用户环境 git --version成功(shim 生效)
  • Stage 3/4:mcpp build / mcpp self init --force失败(复现)
  • Stage 5 探针 B:XLINGS_HOME=~/.mcpp/registrygit --version 应输出 xlings: 'git' is not installed —— 直接证明根因
  • Stage 6:确认 ~/.mcpp/registry/data/*/pkgs 不存在(没有包索引)

分支上删除了其他全部 workflow,仅保留本临时 workflow。验证完后关闭 PR 并删分支。

Removes all other workflows on this branch and adds a single
windows-latest job that:
  - disables the runner's preinstalled Git for Windows
  - installs xlings via the official quick_install.ps1 one-liner
  - runs 'xlings install mcpp', 'mcpp new/build', 'mcpp self init --force'
  - probes 'git --version' with XLINGS_HOME redirected to ~/.mcpp/registry
    to confirm the xvm git-shim / redirected-XLINGS_HOME root cause
@Sunrisepeak
Copy link
Copy Markdown
Member Author

✅ 复现成功 + 根因确认(run 26935094347)

阶段 结果
禁用系统 git 后 xlings install mcpp ✅ 成功(release zip 自带 xim-pkgindex 快照,装到的是快照里的 0.0.36,不是最新版
mcpp new hello ✅ 成功(内置模板,不需要索引)
mcpp build(无 git) failed to bootstrap ninjaauto-installing default toolchain llvm@20.1.7 failed
mcpp self init --force error: init incomplete: ninja missing from sandbox
xlings install xim:git 后用户终端 git --version git version 2.51.0.windows.2(xvm shim)
再次 mcpp build / self init --force(git --version 已 OK) ❌ 错误完全相同

🔫 Smoking gun(Stage 6 probe)

probe A: git --version  (XLINGS_HOME=~/.xlings)        → git version 2.51.0.windows.2 (exit 0)
probe B: git --version  (XLINGS_HOME=~/.mcpp/registry) → [error] xlings: 'git' is not installed (exit 1)

PATH 上的 git.exe 是 xvm shim(xlings 多调用二进制),运行时按 环境变量 XLINGS_HOME 查版本数据库。mcpp 调用 xlings 时把 XLINGS_HOME 重定向到 ~/.mcpp/registry,shim 在该沙箱里查不到 git → 判定 git 不存在;而 git 自举 xlings install xim:git 又需要索引、索引同步只有 git 一条路(无 HTTP 降级)→ 死锁 → registry 沙箱永远没有包索引:

C:\Users\runneradmin\.mcpp\registry\data\xim-pkgindex\pkgs -> exists: False
C:\Users\runneradmin\.xlings\data\xim-pkgindex\pkgs        -> exists: True

详细分析报告见 PR 描述及会话记录。验证完毕后请关闭本 PR 并删除分支。

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