service_complete fails to parse: else on new line after } in packages.nu #147

Closed
opened 2026-04-28 06:08:40 +00:00 by mahmoud · 1 comment
Owner

Symptom

Running service_complete (with no flags) errors out at parse time:

Error: nu::shell::external_command
  × External command failed
     ╭─[tools/modules/services/packages.nu:182:9]
 181 │         if $reset { service_install_all --reset }
 182 │         else if $update { service_install_all --update }
     ·         ──┬─
     ·           ╰── Command `else` not found
 183 │         else { service_install_all }
     ╰────
  help: Did you mean `if`?

Root cause

Nushell requires else / else if to be on the same line as the previous block's closing }. In tools/modules/services/packages.nu at the service_complete function, the Phase 1 (if $core { ... } else { ... }) inner chains were written with } and else split across lines:

    if $core {
        if $reset { service_install_all --core --reset }
        else if $update { service_install_all --core --update }
        else { service_install_all --core }
    } else {
        if $reset { service_install_all --reset }
        else if $update { service_install_all --update }
        else { service_install_all }
    }

The parser interprets the bare else on the next line as an unknown command, so the entire service_complete definition fails to load — meaning the command is unusable for any flag combination, not just the no-flag case.

The rest of packages.nu (lines 62-68 in service_install_all, lines 196-219 in service_complete's Phase 2, lines 254-260 in the WASM phase) uses correctly-formed chains, so this is the only spot that's broken.

Introduced in

Commit 6d1f725feat(skills): service_os wasm_build + --wasm flag on service_complete (#128). The --wasm flag refactor reshaped this Phase 1 block from a single-liner into the multi-line form without joining } and else.

Reproduction

Any invocation of service_complete (with or without flags) on a current Nushell:

use tools/modules/services/packages.nu *
service_complete

Fails with the parse error above. Also blocks service_complete --core, --update, --reset, --wasm, etc.

Fix

Collapse each branch onto a single line, matching the style used at lines 196-219:

    if $core {
        if $reset { service_install_all --core --reset } else if $update { service_install_all --core --update } else { service_install_all --core }
    } else {
        if $reset { service_install_all --reset } else if $update { service_install_all --update } else { service_install_all }
    }

Verified locally on kristof6: nu -c 'use packages.nu *; help service_complete' parses cleanly after the fix.

PR to follow.

## Symptom Running `service_complete` (with no flags) errors out at parse time: ``` Error: nu::shell::external_command × External command failed ╭─[tools/modules/services/packages.nu:182:9] 181 │ if $reset { service_install_all --reset } 182 │ else if $update { service_install_all --update } · ──┬─ · ╰── Command `else` not found 183 │ else { service_install_all } ╰──── help: Did you mean `if`? ``` ## Root cause Nushell requires `else` / `else if` to be on the **same line** as the previous block's closing `}`. In `tools/modules/services/packages.nu` at the `service_complete` function, the Phase 1 (`if $core { ... } else { ... }`) inner chains were written with `}` and `else` split across lines: ```nu if $core { if $reset { service_install_all --core --reset } else if $update { service_install_all --core --update } else { service_install_all --core } } else { if $reset { service_install_all --reset } else if $update { service_install_all --update } else { service_install_all } } ``` The parser interprets the bare `else` on the next line as an unknown command, so the entire `service_complete` definition fails to load — meaning the command is unusable for any flag combination, not just the no-flag case. The rest of `packages.nu` (lines 62-68 in `service_install_all`, lines 196-219 in `service_complete`'s Phase 2, lines 254-260 in the WASM phase) uses correctly-formed chains, so this is the only spot that's broken. ## Introduced in Commit `6d1f725` — *feat(skills): service_os wasm_build + --wasm flag on service_complete (#128)*. The `--wasm` flag refactor reshaped this Phase 1 block from a single-liner into the multi-line form without joining `}` and `else`. ## Reproduction Any invocation of `service_complete` (with or without flags) on a current Nushell: ```nu use tools/modules/services/packages.nu * service_complete ``` Fails with the parse error above. Also blocks `service_complete --core`, `--update`, `--reset`, `--wasm`, etc. ## Fix Collapse each branch onto a single line, matching the style used at lines 196-219: ```nu if $core { if $reset { service_install_all --core --reset } else if $update { service_install_all --core --update } else { service_install_all --core } } else { if $reset { service_install_all --reset } else if $update { service_install_all --update } else { service_install_all } } ``` Verified locally on `kristof6`: `nu -c 'use packages.nu *; help service_complete'` parses cleanly after the fix. PR to follow.
Author
Owner

Fix is up in #148 (branch fix/service-complete-else-147, commit 0501b13).

Diff (single-file, 2 insertions / 6 deletions in tools/modules/services/packages.nu):

     if $core {
-        if $reset { service_install_all --core --reset }
-        else if $update { service_install_all --core --update }
-        else { service_install_all --core }
+        if $reset { service_install_all --core --reset } else if $update { service_install_all --core --update } else { service_install_all --core }
     } else {
-        if $reset { service_install_all --reset }
-        else if $update { service_install_all --update }
-        else { service_install_all }
+        if $reset { service_install_all --reset } else if $update { service_install_all --update } else { service_install_all }
     }

Verified locally on kristof6service_complete now parses and loads. Ready for review.

Fix is up in #148 (branch `fix/service-complete-else-147`, commit `0501b13`). **Diff** (single-file, 2 insertions / 6 deletions in `tools/modules/services/packages.nu`): ```diff if $core { - if $reset { service_install_all --core --reset } - else if $update { service_install_all --core --update } - else { service_install_all --core } + if $reset { service_install_all --core --reset } else if $update { service_install_all --core --update } else { service_install_all --core } } else { - if $reset { service_install_all --reset } - else if $update { service_install_all --update } - else { service_install_all } + if $reset { service_install_all --reset } else if $update { service_install_all --update } else { service_install_all } } ``` Verified locally on `kristof6` — `service_complete` now parses and loads. Ready for review.
mahmoud self-assigned this 2026-04-28 06:10:40 +00:00
mahmoud added this to the ACTIVE project 2026-04-28 06:10:44 +00:00
mahmoud added this to the now milestone 2026-04-28 06:10:46 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#147
No description provided.