Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

autocomplete script: default basename still uses full argv[0] path, Homebrew zsh/bash completion broken

Open
#6,567 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@yfodil is already working on this.

Since Oct 27, 2026.

  • #6569 by @kaovilai — open

Assessment

This issue has not been assessed yet.

Description

autocomplete

Command attempted

scw autocomplete script shell=zsh (and shell=bash / shell=fish) when scw is invoked by absolute path. This is how Homebrew generates completions: the formula runs generate_completions_from_executable(bin/"scw", "autocomplete", "script", shell_parameter_format: :none), which calls the binary by its full Cellar path.

Expected Behavior

The generated script is named after the command (_scw, compdef _scw scw), regardless of how the binary was invoked, so a completion file written from it works.

Actual Behavior

The function and command names are derived from argv[0], so an absolute path ends up in the script:

$ /opt/homebrew/Cellar/scw/2.65.2/bin/scw autocomplete script shell=zsh
autoload -U compinit && compinit
_/opt/homebrew/Cellar/scw/2.65.2/bin/scw () {
	output=($(/opt/homebrew/Cellar/scw/2.65.2/bin/scw autocomplete complete zsh -- ${CURRENT} ${words}))
	...
}
compdef _/opt/homebrew/Cellar/scw/2.65.2/bin/scw /opt/homebrew/Cellar/scw/2.65.2/bin/scw

compdef registers completion for a command literally named /opt/homebrew/.../scw, so plain scw <TAB> falls back to file/directory completion. The bash variant has the same problem (complete -F _/opt/homebrew/.../scw /opt/homebrew/.../scw).

Homebrew writes this output to $(brew --prefix)/share/zsh/site-functions/_scw, so every brew install scw ships zsh completion that silently does nothing. The version-specific Cellar path is also baked in.

A second, smaller problem for the file-in-fpath case: the zsh script has no #compdef scw header, so even with a correct name compinit will not associate an autoloaded _scw file with scw. The current output only works when eval'd.

More info

  • scw version: 2.65.2 (Homebrew bottle arm64_tahoe), macOS 26 / Darwin arm64, zsh 5.9
  • Workaround that confirms the cause: scw autocomplete script shell=zsh basename=scw produces the correct _scw / compdef _scw scw.
  • Related: #3676 reported the same argv[0] problem for bash and was closed by #3829, which added the basename argument. However its default is still core.ExtractBinaryName(ctx) (the full argv[0]), so the output above is unchanged unless every caller passes basename=scw. #1959 (shim/asdf) is the same root cause.

Suggested fix: default basename to filepath.Base(core.ExtractBinaryName(ctx)) (what #3676 originally asked for), and add #compdef scw as the first line of the zsh script. Alternatively, Homebrew could pass basename=scw in the formula, but fixing the default would help every packager and path-based invocation.

[!Note]
Responses generated with Claude (model: Claude Sonnet 5.5)

Dominant language
Go
Stars
1k
Forks
175
Avg merge
1d 1h
Merged PRs (30d)
139

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from scaleway/scaleway-cli

All issues in scaleway/scaleway-cli

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.