Improve autocomplete migration documentation #553

Open
opened 2025-05-01 22:34:44 +00:00 by marlon · 4 comments

Upon upgrading abra, now when trying to use tab to autocomplete, I get this error:
Error: unknown flag: --generate-bash-completion

abra version 0.10.1-beta-2fbef41

Upon upgrading abra, now when trying to use tab to autocomplete, I get this error: `Error: unknown flag: --generate-bash-completion` abra version 0.10.1-beta-2fbef41
Owner

@marlon what command did you run exactly to run into that error?

As noted in the migration docs, the autocomplete commands / flags have changed.

When you run abra autocomplete -h, you should see the necessary commands for bash?

🛠  abra autocomplete -h
To load completions:

Bash:
  # Load autocompletion for the current Bash session
  $ source <(abra autocomplete bash)

  # To load autocompletion for each session, execute once:
  # Linux:
  $ abra autocomplete bash | sudo tee /etc/bash_completion.d/abra
  # macOS:
  $ abra autocomplete bash | sudo tee $(brew --prefix)/etc/bash_completion.d/abra
  ... # omitted for brevity...
@marlon what command did you run exactly to run into that error? As noted [in the migration docs](https://docs.coopcloud.tech/abra/upgrade/#09x-beta-010x-beta), the autocomplete commands / flags have changed. When you run `abra autocomplete -h`, you should see the necessary commands for `bash`? ``` 🛠 abra autocomplete -h To load completions: Bash: # Load autocompletion for the current Bash session $ source <(abra autocomplete bash) # To load autocompletion for each session, execute once: # Linux: $ abra autocomplete bash | sudo tee /etc/bash_completion.d/abra # macOS: $ abra autocomplete bash | sudo tee $(brew --prefix)/etc/bash_completion.d/abra ... # omitted for brevity... ```
Author

Yes, I should have clarified I'm running zsh 5.9 and I ran the following commands per the migration docs:

echo "autoload -U compinit; compinit" >> ~/.zshrc
abra autocomplete zsh > "${fpath[1]}/_abra"

Then I started a new terminal and typed:
abra ap<tab>

The output looks like

➜  ~ abra apError: unknown flag: --generate-bash-completion
Usage:
  abra [command]

Available Commands:
  app          Manage apps
  autocomplete Generate autocompletion script
  catalogue    Manage the recipe catalogue
  help         Help about any command
[...]

When I check the contents of ~/.zshrc it does contain the autoload command, and when I cat "${fpath[1]}/_abra" it shows a script for zsh completion.

Yes, I should have clarified I'm running zsh 5.9 and I ran the following commands per the migration docs: ``` echo "autoload -U compinit; compinit" >> ~/.zshrc abra autocomplete zsh > "${fpath[1]}/_abra" ``` Then I started a new terminal and typed: `abra ap<tab>` The output looks like ``` ➜ ~ abra apError: unknown flag: --generate-bash-completion Usage: abra [command] Available Commands: app Manage apps autocomplete Generate autocompletion script catalogue Manage the recipe catalogue help Help about any command [...] ``` When I check the contents of ~/.zshrc it does contain the autoload command, and when I `cat "${fpath[1]}/_abra"` it shows a script for zsh completion.
Owner

@marlon do you perhaps still have the old pre v0.10.x autocomplete config lying around?

cli/cli.go Lines 91 to 96 in e3a0af5840
fmt.Println(fmt.Sprintf(`
# Run the following commands to install auto-completion
sudo mkdir /etc/zsh/completion.d/
sudo cp %s /etc/zsh/completion.d/abra
echo "PROG=abra\n_CLI_ZSH_AUTOCOMPLETE_HACK=1\nsource /etc/zsh/completion.d/abra" >> ~/.zshrc
# To test, run the following: "abra app <hit tab key>" - you should see command completion!

if [[ "$cur" == "-"* ]]; then
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
else
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
fi

@marlon do you perhaps still have the old pre v0.10.x autocomplete config lying around? https://git.coopcloud.tech/toolshed/abra/src/commit/e3a0af5840553c2c5a1a5135f474afb90c7f4375/cli/cli.go#L91-L96 https://git.coopcloud.tech/toolshed/abra/src/commit/e3a0af5840553c2c5a1a5135f474afb90c7f4375/scripts/autocomplete/zsh#L8-L12
Author

Yes, seems the problem was that I had this pre v0.10.x line in my .zshrc file:
source /etc/zsh/completion.d/abra

Removing that line fixed the error.

Yes, seems the problem was that I had this pre v0.10.x line in my `.zshrc` file: `source /etc/zsh/completion.d/abra` Removing that line fixed the error.
decentral1se added the
documentation
label 2025-05-03 06:50:22 +00:00
decentral1se added this to the Documentation project 2025-05-03 06:50:30 +00:00
decentral1se changed title from Autocomplete fails: "unknown flag: --generate-bash-completion" to Improve autocomplete migration documentation 2025-05-03 11:59:59 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: toolshed/abra#553
No description provided.