#1070074 several errors on tab completion

#1070074#5
Date:
2024-04-29 18:41:12 UTC
From:
To:
Upgrading from  1:2.11-8 to 1:2.12.0-1 causes several errors at tab
completion or starting bash.

...
bash: _comp_deprecate_func: command not found
bash: _comp_deprecate_var: command not found
bash: _comp_deprecate_var: command not found
bash: _comp_deprecate_var: command not found
bash: _comp_have_command: command not found
bash: _comp_have_command: command not found
...

Reverting to previous version didn't help.

This was due to util-linux-extra being put on hold, since once I updated
2.40-5 -> 2.40-8
util-linux-extra
util-linux
eject
bsdextrautils
libsmartcols1
libblkid1
libmount1
mount
libuuid1
util-linux
libfdisk1

the problem went away.

Probably some version dependency should be added.

thanks

#1070074#10
Date:
2024-04-30 13:38:33 UTC
From:
To:
I doubt this issue is related to util-linux-extra being too old.

I had a similar error while pressing "sudo<tab>" I got the error:
"sudo bash: _comp_initialize : commande introuvable"
ie "commande introuvable" is "command not found".

It turned out that this error only happens in bash shell I had opened
before the upgrade (the fact you had the issue opening new bash shell is
awakward to me). The bash shell I opened after were fine.

Note the _comp_deprecate_var, _comp_xxx functions are defined in /usr/share/bash-completion/bash_completion
which is part of the bash-completion package, so upgrading
util-linux-extra can have no effect on them being present or not.

From the error I got above I guess bash completion /usr/share/bash-completion/completions/*
might get source anew after upgrade while the
/usr/share/bash-completion/bash-completion common function definition
file is not.
A way to workaround this issue would be to source this file in existing
bash shells: "source /usr/share/bash-completion/bash_completion" indeed
fixed my shell with broken "sudo<tab>" and missing _comp_initialize
command.

I see no easy fix as as far as I know, the /usr/share/bash-completion/bash_completion
is imported when the bash shell is started (profile file or bashrc) but it seems the
completion files can be source during the shell runtime.
Maybe the a check at each completion files function call could be added
to check if /usr/share/bash-completion/bash_completion has changed and
source it when so. But this looks more like an upstream issue
than a Debian specific topic.

NB: I still do not understand why you got the "command not found" when
opening a new bash shell. The new
/usr/share/bash-completion/bash_completion is source from the latest
version at this point.
Maybe your $HOME/.bashrc is not up to date:

/etc/skel/.bashrc: (should be in your $HOME/.bashrc)
# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac
(...)
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi


/etc/bash.bashrc:
# enable bash completion in interactive shells
#if ! shopt -oq posix; then
#  if [ -f /usr/share/bash-completion/bash_completion ]; then
#    . /usr/share/bash-completion/bash_completion
#  elif [ -f /etc/bash_completion ]; then
#    . /etc/bash_completion
#  fi
#fi

or it is not imported from your $HOME/.profile which should have:
# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi


but even then /etc/profile should have source the common bash completion functions:
/etc/profile:
/etc/profile.d/bash_completion.sh
# shellcheck shell=sh disable=SC1091,SC2166,SC2268,SC3028,SC3044,SC3054
# Check for interactive bash and that we haven't already been sourced.
if [ "x${BASH_VERSION-}" != x -a "x${PS1-}" != x -a "x${BASH_COMPLETION_VERSINFO-}" = x ]; then

    # Check for recent enough version of bash.
    if [ "${BASH_VERSINFO[0]}" -gt 4 ] ||
        [ "${BASH_VERSINFO[0]}" -eq 4 -a "${BASH_VERSINFO[1]}" -ge 2 ]; then
        [ -r "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion" ] &&
            . "${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion"
        if shopt -q progcomp && [ -r /usr/share/bash-completion/bash_completion ]; then
            # Source completion code.
            . /usr/share/bash-completion/bash_completion
        fi
    fi

fi



Cheers
Alban