cobra icon indicating copy to clipboard operation
cobra copied to clipboard

Incorrect file location in suggested zsh autocompletion setup command on Manjaro

Open tarlacac opened this issue 2 months ago • 3 comments

Apologies in advance, I am not a Go developer so I don't have a great understanding of the implementation details (this is my first time actually looking at code in the language!).

Did you look for related issues?

I did not find anything specifically discussing this, but I found another issue recommending the command that is not working for me (#1165, but the link to the instructions they followed does not exist anymore), a similar issue on an M1 mac (#1589), an issue discussing incorrect zsh configuration inhibiting their completions (#1534), an older issue about a different command for zsh completion (#1529), and a few others that were less relevant about zsh completions.

Describe the bug

The zsh completion generation help message does not work to load completions for every new session on Manjaro Linux (and I'm guessing Arch Linux, too). This appears to be because ${fpath[1]} defaults to /usr/local/share/zsh/site-functions, but that directory does not exist. Instead, /usr/share/zsh/site-functions is being used, which appears to be the default location from inspecting the PKGBUILD files for extra/zsh and extra/zsh-completions, and is the value of ${fpath[2]}.

To Reproduce

Steps to reproduce the behavior:

  1. On Manjaro, in a terminal, run a program with the default completion command (I was using fan2go when I found this) to get the instructions:
<program> completion zsh --help
  1. Following the instructions for Linux, run <program> completion zsh > "${fpath[1]}/_<program>"
  2. See error:
% <program> completion zsh > "${fpath[1]}/_<program>"
zsh: no such file or directory: /usr/local/share/zsh/site-functions/_<program>
  1. Verify /usr/local/share/zsh does not exist:
% ls /usr/local/share/zsh
ls: cannot access '/usr/local/share/zsh': No such file or directory
  1. Verify /usr/share/zsh exists:
% ls /usr/share/zsh
5.9/	    manjaro-zsh-config	p10k-portable.zsh  plugins/  site-functions/
functions/  manjaro-zsh-prompt	p10k.zsh	   scripts/  zsh-maia-prompt

Expected behavior My zsh site-functions directory is /usr/share/zsh/site-functions, so I would expect the recommended command to use that directory. Alternatively, it would be nice to have a note warning that the location might be /usr/share/zsh/site-functions instead of /usr/local/share/zsh/site-functions.

Desktop (please complete the following information):

  • Distro: Manjaro
  • uname -a: Linux <hostname> 6.6.54-2-MANJARO #1 SMP PREEMPT_DYNAMIC Tue Oct 8 03:11:08 UTC 2024 x86_64 GNU/Linux
  • zsh --version: zsh 5.9 (x86_64-pc-linux-gnu)

Additional context

I am coming from fan2go, where I submitted an issue and was told this particular help command output was generated by cobra. I do know that they are using the latest version of cobra (v1.8.1 at the time of writing), and I could not find custom code for this subcommand, so I believe the help message was generated by cobra.

As far as I know, I have not done any configuration to zsh except a few p10k configure calls for the theme. From some brief searching, it appears that zsh using either /usr/share or /usr/local/share varies based on Linux distro. It is possible that zsh is misconfigured somewhere as well, but I couldn't find anything configuring fpath to use these defaults on my system.

tarlacac avatar Dec 01 '24 02:12 tarlacac