Skip to content

fix(cli): update replaces an ash in a read-only bin dir in place - #7

Merged
Arismemo merged 1 commit into
mainfrom
fix/cli-update-in-place
Sep 25, 2026
Merged

Arismemo merged 1 commit into
mainfrom
fix/cli-update-in-place

Conversation

@Arismemo

Copy link
Copy Markdown
Owner

问题

ash 所在目录不可写(root 建的 /usr/local/bin 里放着本人的 ash、又没有免密 sudo)时,安装和 ash update 会在 ~/.local/bin 另装一份,PATH 里更靠前的旧版本永远不会被替换,非交互 shell(ssh 命令、部分 Agent 工具)一直在跑旧 CLI。实际在 100.70.70.3 上遇到:/usr/local/bin 里是重写前的老 CLI(没有 update 命令,只打印帮助),新 CLI 装在了 ~/.local/bin。

修复

  • 目录不可写但 ash 文件本身可写:原地覆盖
  • 装到别处后,PATH 里更靠前的 ash 仍遮住新版本时明确提示
  • ash update 改写完立即退出,bash 不会接着读被改写的脚本

测试

  • 新增:只读目录里的 ash 被原地替换且不在别处另装一份;被遮挡时给出提示
  • 两个新测试在修复前的 cli.sh 上都失败,修复后通过
  • npm run check:UI 29、server 58 全部通过

🤖 Generated with Claude Code

When `ash` lived in a directory the user can't write (root-owned
/usr/local/bin holding a user-owned ash, no passwordless sudo), install
and `ash update` wrote a second copy to ~/.local/bin and left the old one
first on PATH, so non-interactive shells kept running the stale CLI.

- if the directory isn't writable but the ash file is, overwrite it in place
- after installing elsewhere, warn when an earlier ash on PATH still shadows it
- `ash update` exits right after the rewrite so bash doesn't keep reading
  the file it just replaced

Found on a machine where the pre-rewrite CLI (no `update` command) sat in
/usr/local/bin while the new one had been installed into ~/.local/bin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Arismemo
Arismemo merged commit 4e95a2c into main Sep 25, 2026
2 checks passed
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