#950123 virtualenvwrapper: Autocomplete not loaded in default install

#950123#5
Date:
2020-01-29 02:42:53 UTC
From:
To:
Hi virtualenvwrapper maintainers,

virtualenvwrapper doesn't seem to load from the autocomplete launcher in a clean
chroot (created via debootstrap). I've tried digging to why this is, but I'm not
familiar enough with bash's autocomplete to work out whether this is a
virtualenvwrapper bug or a bash-completion bug. My tests have been to add printf
lines to the autocomplete code, but these never appear to print (whether that's
because I've done something wrong, or something else, I'm not sure). Strangely,
this works fine in on my main system, it's in containers or chroots that seem to
be the problem.

#950123#10
Date:
2020-08-29 05:56:14 UTC
From:
To:
Hi,

I can confirm that despite what is stated on
/usr/share/doc/virtualenvwrapper/README.Debian,
virtualenvwrapper_4.8.4-4, doesn't install
/etc/bash_completion.d/virtualenvwrapper, as it was the case in the
version found on Buster (4.3.1-2).

Regards,

David Polverari.

#950123#15
Date:
2021-12-15 15:07:43 UTC
From:
To:
In a buster upgraded to bullseye, this was working. But in a clean bullseye
installation, it doesn't seem to be working.

Note that /etc/bash_completion.d seems to be deprecated and moved to
/usr/share/bash-completion/completions. Your .bashrc might still be loading
stuff from /etc (which might still contain buster's virtualenvwrapper stuff).
The correct things to put in your .bashrc are in /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

(These lines are initially commented out. Also, obviously you might prefer to
uncomment these lines and source /etc/bash.bashrc from your .bashrc instead of
copying them).

I've experimented a bit and bash seems to be loading completions alright from
/usr/share/bash-completion/completions. Therefore it seems most likely that this
is a virtualenvwrapper problem.

#950123#20
Date:
2022-03-09 08:25:16 UTC
From:
To:
Hi,
I believe the issue is that the scripts in
/usr/share/bash-completion/completions should be different than the ones
that live in /etc/bash_completion.d. The mechanisms are different.
Therefore the current script should still live in /etc/bash_completion.d.

So I quickly fixed this by adding a symbolic link and now this works as
expected.

I believe that with the "new" way, there's no need for a lazy vs not lazy
script, because the new way works by itself in a lazy fashion.

Hope this helps!

#950123#25
Date:
2022-03-09 13:08:08 UTC
From:
To:
After thinking about this a bit more, I believe this is abusing te
bash_completion mechanism and the script could probably move elsewhere such
as /etc/profile.d.

Thoughts?