Skip to content

fix(cli): zsh completion _arguments error and compinit registration failure - #19441

Closed
0xbboyd wants to merge 1 commit into
NousResearch:mainfrom
0xbboyd:fix/cli-zsh-completion-arguments-error
Closed

fix(cli): zsh completion _arguments error and compinit registration failure#19441
0xbboyd wants to merge 1 commit into
NousResearch:mainfrom
0xbboyd:fix/cli-zsh-completion-arguments-error

Conversation

@0xbboyd

@0xbboyd 0xbboyd commented May 4, 2026

Copy link
Copy Markdown

Problem

Running eval "$(hermes completion zsh)" in ~/.zshrc produces two bugs:

  1. _arguments:comparguments:327: can only be called from completion function — The generated zsh script ends with _hermes "$@", which executes outside any completion context at shell init time, triggering _arguments errors on every new terminal.

  2. Completions never register — The #compdef hermes directive at the top of the output is only processed by compinit when reading files from fpath, not when eval-'d as a string. So eval "$(hermes completion zsh)" silently fails to set up completions.

Fix

  • Remove the trailing _hermes "$@" from generate_zsh() output. The completion function should only be invoked by zsh's completion system, not at definition time.
  • Update the installation comment to recommend the file-based approach that actually works with compinit:
    hermes completion zsh > ~/.zsh/completions/_hermes
    # Ensure fpath includes that directory before compinit

Testing

Verified locally that generate_zsh() output:

  • Ends with }} (function close), not _hermes "$@"
  • Contains #compdef hermes directive
  • Recommends file-based installation via fpath
  • Does not contain eval in the installation instructions

Fixes #19439

Platforms tested

  • Linux (zsh 5.9)

The generated zsh completion script ended with _hermes "$@", which
gets executed at eval time (shell init) outside any completion context,
causing _arguments:comparguments:327: can only be called from completion
function on every new shell session.

Additionally, the #compdef hermes directive is only processed by compinit
when loaded from a file in fpath, not when eval'd as a string. This means
eval "$(hermes completion zsh)" silently fails to register completions.

Fixes:
- Remove trailing _hermes "$@" call from generate_zsh() output
- Update installation comment to recommend file-based approach

Fixes NousResearch#19439

Co-authored-by: hermes-claude-sonnet-4 <hermes-claude-sonnet-4@users.noreply.github.com>
@0xbboyd 0xbboyd closed this May 4, 2026
@alt-glitch alt-glitch added type/bug Something isn't working comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels May 4, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Fixes #19439 which is duplicate of #6122. Overlaps with #11754, #9618, and #6141 which address the same _hermes "$@" issue.

@alt-glitch

Copy link
Copy Markdown
Collaborator

Overlaps with existing fix PRs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): zsh completion generates _arguments error and does not register with compinit

2 participants