service_proc.nu: rm -f $sock | complete breaks stop when running as root #79

Closed
opened 2026-04-19 15:09:45 +00:00 by mahmoud · 1 comment
Owner

While running the comprehensive test for #77, service_proc stop --root invoked as root (against root's own hero_proc) failed with:

Error: nu::shell::error
  × Complete only works with external commands
     ╭─[service_proc.nu:270:34]
 269 │         } else {
 270 │             do { rm -f $sock } | complete | ignore
     ·                                  ──────┬───
     ·                                        ╰── complete only works on external commands

Root cause

rm is a Nushell built-in, so do { rm -f $sock } | complete is rejected. The sister branch (line 268) uses ^sudo rm which is external, so it works — only the plain rm branch has the bug.

When it triggers

Path taken when svc_need_sudo $root returns false (i.e. the invoking user is already root and targeting root's hero_proc) and the socket file still exists at cleanup time.

Fix

Change rm^rm so Nushell treats it as an external command:

} else {
    do { ^rm -f $sock } | complete | ignore
}

One-line change. Verified on the Hetzner box during the #77 test (patched in place, test passed, patch reverted).

Out of scope for this issue

Belongs in its own PR per the #75 / per-service flow. Feel free to pick this up as a quick drive-by fix for whoever takes it next.

While running the comprehensive test for #77, `service_proc stop --root` invoked as root (against root's own hero_proc) failed with: ``` Error: nu::shell::error × Complete only works with external commands ╭─[service_proc.nu:270:34] 269 │ } else { 270 │ do { rm -f $sock } | complete | ignore · ──────┬─── · ╰── complete only works on external commands ``` ### Root cause `rm` is a Nushell built-in, so `do { rm -f $sock } | complete` is rejected. The sister branch (line 268) uses `^sudo rm` which is external, so it works — only the plain `rm` branch has the bug. ### When it triggers Path taken when `svc_need_sudo $root` returns false (i.e. the invoking user is already root and targeting root's hero_proc) **and** the socket file still exists at cleanup time. ### Fix Change `rm` → `^rm` so Nushell treats it as an external command: ```nushell } else { do { ^rm -f $sock } | complete | ignore } ``` One-line change. Verified on the Hetzner box during the #77 test (patched in place, test passed, patch reverted). ### Out of scope for this issue Belongs in its own PR per the #75 / per-service flow. Feel free to pick this up as a quick drive-by fix for whoever takes it next.
Member

PR #114 fixes it in commit ce7d16b

PR #114 fixes it in commit ce7d16b
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_skills#79
No description provided.