Incus auto-complete for nested vm

I get a recurring minor inconvenience I’d like to report/inquire-about.

I install incus on bare metal, and everything works. Sometimes, I create an incus VM and then use that to hold nested Incus containers/vm’s. It all works as I expect, except for…auto-complete for incus commands, which never works. It happens in all of my nested vm’s when I install incus in them. And in both Debian and Ubuntu, e.g. this:

User root@/root/
root@archive:~# incus list
+------------------------+---------+------+------+-----------+-----------+
|          NAME          |  STATE  | IPV4 | IPV6 |   TYPE    | SNAPSHOTS |
+------------------------+---------+------+------+-----------+-----------+
| Fastcloud-Week-02      | STOPPED |      |      | CONTAINER | 2         |
+------------------------+---------+------+------+-----------+-----------+
| OGSelfHosting-Week-02  | STOPPED |      |      | CONTAINER | 2         |
+------------------------+---------+------+------+-----------+-----------+
| SysAdmin-22-04-Week-02 | STOPPED |      |      | CONTAINER | 3         |
+------------------------+---------+------+------+-----------+-----------+
root@archive:~# incus start Fa      #(hitting tab does nothing)
Error: Failed to fetch instance "Fa" in project "Week-02": Instance not found
root@archive:~# incus start Fastcloud-Week-0     #Even here!
Error: Failed to fetch instance "Fastcloud-Week-0" in project "Week-02": Instance not found
root@archive:~# incus start Fastcloud-Week-02
root@archive:~# incus list    #Nothing odd about the name, it does exist and even start when you type it in full:
+------------------------+---------+---------------------+-----------------------------------------------+-----------+-----------+
|          NAME          |  STATE  |        IPV4         |                     IPV6                      |   TYPE    | SNAPSHOTS |
+------------------------+---------+---------------------+-----------------------------------------------+-----------+-----------+
| Fastcloud-Week-02      | RUNNING | 10.68.36.180 (eth0) | fd42:ed0c:32b9:bff7:216:3eff:fe3c:c4aa (eth0) | CONTAINER | 2         |
+------------------------+---------+---------------------+-----------------------------------------------+-----------+-----------+
| OGSelfHosting-Week-02  | STOPPED |                     |                                               | CONTAINER | 2         |
+------------------------+---------+---------------------+-----------------------------------------------+-----------+-----------+
| SysAdmin-22-04-Week-02 | STOPPED |                     |                                               | CONTAINER | 3         |
+------------------------+---------+---------------------+-----------------------------------------------+-----------+-----------+
root@archive:~# 

A populated autocomplete file exists where I expect it:

root@archive:~# ls /usr/share/bash-completion/completions/incus 
/usr/share/bash-completion/completions/incus
root@archive:~# 

Am I unique with this experience; is this supposed to be this way? What, if anything, am I missing?

V/R

Andrew

This simply means there’s something different between your bare metal host and the VMs you have created.

It’s much easier if we talk about an exact set of steps to reproduce the problem. This is with incus 6.0.3:

$ incus launch images:ubuntu/22.04/cloud --vm foobar
$ incus shell foobar
# apt-get -y install curl
# curl -fsSL https://pkgs.zabbly.com/key.asc -o /etc/apt/keyrings/zabbly.asc
# sh -c 'cat <<EOF > /etc/apt/sources.list.d/zabbly-incus-lts-6.0.sources
Enabled: yes
Types: deb
URIs: https://pkgs.zabbly.com/incus/lts-6.0
Suites: $(. /etc/os-release && echo ${VERSION_CODENAME})
Components: main
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/zabbly.asc

EOF'
# apt-get update
# apt-get -y install incus
...
# incus admin init
... take defaults for everything
# incus launch images:ubuntu/22.04/cloud bazqux
# incus stop b<tab>      NO AUTOCOMPLETE

Is this is your problem? Once reproduced, it’s easy to debug.

I find that the VM doesn’t have /etc/bash_completion or /usr/share/bash-completion/bash_completion. This can be fixed by installing the missing package:

# apt-get -y install bash-completion

And then, logout and login:

# exit
$ incus shell foobar
# incus stop b<tab>  ==>  bazqux

Works for me now.

If that doesn’t fix your problem, then please give an exact series of steps to reproduce.

2 Likes

If using incus exec BLAH bash you’ll need to do . /etc/bash_completion to load the completion profiles into your shell, incus shell goes through the full login sequence which then avoids that.

2 Likes

You nailed it straight away - missing package. Doh. THANK YOU.

I often use Debian VM images and they are light, so I have just added:

apt install bash-completion

…to my vm init script, which I pull down and run every time I crate a vm.

This one improvement saves me a lot of typing as I have long container names (dates and all such appended) in my archiving vm’s!! It was such an annoyance. I should have asked sooner, or better yet, been smart enough to solve this myself! Hey ho.

THANK YOU again!!

Andrew

1 Like