fix(sandbox): 预建 venv + orchestrator 每次 exec 注入 VIRTUAL_ENV/PATH/HOME

之前发现:LLM 写 \`uv pip install --system pandas\`(PEP 668 后的默认姿势),
sandbox 用户没权写 /usr/local/lib/python3.13,-system 失败。

修法:
- patch-venv.sh: 镜像里预建 /home/sandbox/.venv(chown 给 sandbox)
- incus.ts exec wrapper: 当 user=1000 时自动注入 VIRTUAL_ENV + PATH + HOME
- 其中 PATH 把 .venv/bin 放最前,保证 python3/pip/uv 都走 venv
- /etc/environment 不走 PAM 所以不生效(之前踩的坑),换到 --env flag

验证:pandas 场景(写 csv + read + describe/sum/mean)完全跑通。
镜像 fingerprint b5d1c8333c5a (502MiB)。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-19 21:40:10 +08:00
parent 98e8486bcf
commit 5f6f07b9d6

View File

@@ -202,6 +202,13 @@
"message": "auto-save 2026-04-19 21:34 (~1)",
"hash": "05dc59d",
"files_changed": 1
},
{
"ts": "2026-04-19T21:39:57+08:00",
"type": "commit",
"message": "auto-save 2026-04-19 21:39 (+1, ~2)",
"hash": "98e8486",
"files_changed": 3
}
]
}