Skip to content

emrg: fix macOS pkg user-level install — --install-location + currentUserHome domain - #409

Merged
argszero merged 2 commits into
masterfrom
feature/macos-pkg-user-level-install
Aug 5, 2026
Merged

emrg: fix macOS pkg user-level install — --install-location + currentUserHome domain#409
argszero merged 2 commits into
masterfrom
feature/macos-pkg-user-level-install

Conversation

@argszero

@argszero argszero commented Aug 5, 2026

Copy link
Copy Markdown
Owner

背景

rant 2026-08-05T18:45:35:v0.2.3 macOS arm64 pkg 双击/命令行安装均报「软件包正尝试将内容安装到系统宗卷」。

根因(双重 bug)

  1. pkgbuild 未指定 --install-location → 默认安装位置为系统宗卷 / → 用户级安装被 macOS 拒绝
  2. postinstall 复制源 /tmp/emrg-payload构建机路径:构建时创建、打包后立即 rm -rf → 用户机安装时空复制(无 set -e,cp 失败仍 exit 0)

修复

  • payload 去掉 runtime/ 嵌套层,直接放 runtime 内容
  • pkgbuild --install-location '/.emrg/install'(currentUserHome 域下相对 home 锚点)
  • productbuild --distribution<domains enable_currentUserHome="true" enable_localSystem="false"/> → 安装器显示「仅当前用户」,无需系统卷权限
  • postinstall 重写:$2(安装器传入真实位置)替代 /tmp 假想路径,仅做 chown(R105)+ GUI 复制到 ~/Applications/(R104),保留 R67 控制台用户 HOME 检测

验证(本机 macOS arm64 实测)

  • pkgbuild + productbuild 构建成功,install-location="/.emrg/install" + currentUserHome 域确认
  • installer -pkg ... -target CurrentUserHomeDirectory 安装成功("Installing at base path /Users/argszero")
  • 安装后 ~/.emrg/install/bin/emrg 可运行;~/Applications/EMRG.app + 卸载 EMRG.app 均就位
  • 回归:470 pytest 全绿 + import check + emrg --help OK

…UserHome domain (rant 2026-08-05T18:45:35)

双 bug 修复:
1. pkgbuild 未指定 --install-location → 默认装系统宗卷 / → '软件包正尝试将内容安装到系统宗卷' 报错
2. postinstall 复制源 /tmp/emrg-payload 为构建机路径,打包后立即删除 → 用户安装空复制

改法:payload 去掉 runtime/ 层,pkgbuild --install-location '/.emrg/install'
+ productbuild distribution currentUserHome 域(enable_localSystem=false)
→ 引擎直接装 ~/.emrg/install/,postinstall 只做 chown + GUI 复制到 ~/Applications/

本机实测:pkgbuild+productbuild 构建成功,installer -pkg 安装到
~/ .emrg/install(emrg 可运行)+ ~/Applications/EMRG.app + 卸载 EMRG.app

@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

已 review diff:payload 去 runtime/ 层 + pkgbuild --install-location '/.emrg/install' + productbuild currentUserHome 域(enable_localSystem=false)+ postinstall 用 $2 替代 /tmp 假想路径,双 bug 修复逻辑正确。本机 macOS arm64 实测 installer -pkg 安装成功(~/.emrg/install/bin/emrg 可运行 + ~/Applications/EMRG.app 就位),CI test 通过。

rant 2026-08-05T18:45:35 验收项:安装后 emrg 命令可用(pkg postinstall 写
shell rc anchor R19)。Windows 有 HKCU PATH、Linux AppImage 有 ~/.local/bin
软链,唯 macOS 缺 —— 本 commit 补上:

- postinstall 写 shell rc PATH anchor(# >>> EMRG PATH >>> 标记),格式与
  bin/emrg-uninstall clean_environment() 完全一致(卸载对称清理)
- 幂等:任一 rc 已含 anchor 则跳过;写所有存在的 rc(zsh 默认 + bash 兼容),
  无 rc 兜底创建 ~/.zshrc(macOS 默认 zsh)
- 验证:临时 HOME 实测安装写入 anchor、重复安装不重复写、
  clean_environment regex 可完整匹配清理;470 pytest 全绿
@argszero

argszero commented Aug 5, 2026

Copy link
Copy Markdown
Owner Author

补充 commit f0cae96:postinstall 增加 shell rc PATH anchor(R127/R19)——macOS 安装后 emrg 命令直接可用(Windows 有 HKCU PATH、Linux 有 ~/.local/bin 软链,macOS 此前缺失)。anchor 标记与 emrg-uninstall 的 clean_environment() 对称(卸载自动清理),幂等写入。

验证:临时 HOME 实测写入 ~/.zshrc、重复安装不重复、卸载 regex 完整匹配;470 pytest 全绿。

@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

补充 commit f0cae96 已 review:postinstall PATH anchor 段逻辑正确 —— grep 幂等检查覆盖 4 个 rc、写存在 rc 且兜底创建 ~/.zshrc、anchor 标记与 bin/emrg-uninstall 的 PATH_ANCHOR_START/END 完全一致(卸载对称)。本机实测写入 + 幂等 + 卸载匹配均通过。

@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

第 3 个不同 cycle 的 LGTM。代码已在 cycle-185422(本机安装实测)与 cycle-190805(PATH anchor 注入实测)分别验证,diff 无变化,CI test 通过。满足合并条件(连续 3 cycle ✅ 无 ❌),执行 merge。

@argszero
argszero merged commit e552eb7 into master Aug 5, 2026
1 check passed
argszero added a commit that referenced this pull request Aug 5, 2026
rant 2026-08-05T18:45:35 验收项:v0.2.4(或下个版本)macos-arm64.pkg 双击安装
无系统卷报错。master 已合入 #409(--install-location + currentUserHome 域 +
postinstall PATH anchor),本次 bump 0.2.3 → 0.2.4 并推 tag 触发发布链:

- #409 macOS pkg 用户级安装双 bug 修复(系统宗卷 + /tmp 假想路径)
- #409 补充:postinstall shell rc PATH anchor(R127/R19)

版本文件 6 处同步:pyproject.toml / __init__.py / uv.lock /
make-installer.sh / build-runtime.sh / gui package.json

Co-authored-by: argszero <argszero@argszerodeMac-mini.local>
argszero added a commit that referenced this pull request Aug 5, 2026
#409 merge 后 macOS pkg 安装会写 shell rc PATH anchor(R127/R19),
新开终端直接 emrg 命令可用。README 中英双版此前只写 Linux 软链,
未提 macOS PATH —— 同步补齐。

Co-authored-by: argszero <argszero@argszerodeMac-mini.local>
@argszero
argszero deleted the feature/macos-pkg-user-level-install branch August 5, 2026 12:03
argszero added a commit that referenced this pull request Aug 5, 2026
v0.2.4 修复 macOS pkg 系统宗卷问题后为纯用户级安装(enable_currentUserHome + localSystem=false),README macOS 行补充'无需管理员密码',对齐 Windows 行'免 UAC'表述。中英双版同步。

Co-authored-by: EMRG Evolution <emrg@argszero.dev>
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