Bash completion is broken(again) on ubuntu 22.04

/usr/share/bash-completion/completions/lxc and /usr/share/bash-completion/completions/lxd.lxc symlink is installed, and bash did tries to invoke /snap/snapd/current/usr/lib/snapd/complete.sh, but nothing happens.

I need to install /snap/lxd/current/etc/bash_completion.d/snap.lxd.lxc symlink manually under /etc/bash_completion.d

Happens both on 5.2 and 5.3 snap packages.

alvin@alvin-WS-E500:~$ lxc con+ local etel=snap/core/current/usr/lib/snapd/etelpmoc.sh
++ command -v lxc
+ [[ /snap/bin/lxc =~ ^(/var/lib/snapd)?/snap/bin/ ]]
+ [[ -e /var/lib/snapd/snap/core/current/usr/lib/snapd/etelpmoc.sh ]]
+ [[ -e /snap/core/current/usr/lib/snapd/etelpmoc.sh ]]
+ _completion_loader lxc
+ local cmd=lxc
+ __load_completion lxc
+ dirs=('/home/alvin/.local/share/bash-completion/completions')
+ local -a dirs
+ local 'ifs= 	
' IFS=: dir cmd=lxc compfile
+ [[ -n lxc ]]
+ for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}
+ dirs+=($dir/bash-completion/completions)
+ for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}
+ dirs+=($dir/bash-completion/completions)
+ for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}
+ dirs+=($dir/bash-completion/completions)
+ for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}
+ dirs+=($dir/bash-completion/completions)
+ for dir in ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}
+ dirs+=($dir/bash-completion/completions)
+ IFS=' 	
'
+ [[ /usr/share/bash-completion/bash_completion == */* ]]
+ dirs+=("${BASH_SOURCE%/*}/completions")
+ local backslash=
+ [[ lxc == \\* ]]
+ for dir in "${dirs[@]}"
+ [[ -d /home/alvin/.local/share/bash-completion/completions ]]
+ continue
+ for dir in "${dirs[@]}"
+ [[ -d /usr/share/ubuntu-xorg/bash-completion/completions ]]
+ continue
+ for dir in "${dirs[@]}"
+ [[ -d /usr/share/gnome/bash-completion/completions ]]
+ continue
+ for dir in "${dirs[@]}"
+ [[ -d /usr/local/share//bash-completion/completions ]]
+ continue
+ for dir in "${dirs[@]}"
+ [[ -d /usr/share//bash-completion/completions ]]
+ for compfile in "$cmd" "$cmd.bash" "_$cmd"
+ compfile=/usr/share//bash-completion/completions/lxc
+ [[ -f /usr/share//bash-completion/completions/lxc ]]
+ . /usr/share//bash-completion/completions/lxc
+ [[ -n '' ]]
+ return 0
+ return 124
1 Like

@Jih-Kai_Liang thanks for reporting this. :+1: I am seeing the same thing on Debian bookworm (i.e. Debian 12, not yet released).

lxd 5.5-37534be running as a snap (regretfully, can’t wait until Debian bug #768073 is resolved and we a have a native non-snap package in the distro)

Creating the symlink like this worked for now:

$ cd /etc/bash_completion.d/
$ sudo ln -sf /snap/lxd/current/etc/bash_completion.d/snap.lxd.lxc .

The lxc con+ command you pasted doesn’t work at all for me though:

$ lxc con+ local etel=snap/core/current/usr/lib/snapd/etelpmoc.sh
Error: unknown command "con+" for "lxc"

Did you mean this?
	copy

Any thoughts on this @stgraber ?

Not something we have any control over. We provide a completion script and tell snapd to put it in place. If that’s not working properly, then that’s most likely a snapd bug or a packaging bug in the distro.

1 Like