Importing an image fails with "Error: Metadata tarball is missing metadata.yaml"

Hi!

I wanted to improve my image building to simultanously create an ‘incus’ image and a ‘lxc’ image, and to make it easier to keep images current:

$ sudo distrobuilder --cache-dir ../cache/ --timeout 7200 build-dir debian-13-with-ssh.yaml rootfs -o image.serial=20251029-2046 -o image.architecture=x86_64 -o image.release=trixie
$ sudo distrobuilder pack-lxc debian-13-with-ssh.yaml ./rootfs ./out-lxc
$ incus image import out-lxc/rootfs.tar.xz out-lxc/meta.tar.xz  image.serial=20251029-2053 image.architecture=x86_64 image.release=trixie --alias on-debian-c-13-1 -v
Error: Metadata tarball is missing metadata.yaml

If I look into out-lxc/meta.tar.xz, the file is indeed not there:

$ tar tJf out-lxc/meta.tar.xz    
create-message
expiry
excludes-user
config
config-user
config-user.1
config-user.2
config-user.3
config-user.4
config.1
config.2
config.3
config.4
templates

I haven’t looked into these other files, and I’ve read that it should be easy to manually create such a metadata.yaml file, but I’d prefer if the tool created it for me.

Am I doing something wrong? Or did I stumble across a bug?

I’m currently running

$ dpkg -l incus incus-extra  
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version                      Architecture Description
+++-==============-============================-============-===========================================
ii  incus          1:6.17-debian12-202510170209 amd64        Incus - Container and virtualization daemon
ii  incus-extra    1:6.17-debian12-202510170209 amd64        Incus - Extra tools

on a Trixie machine.

You would need to pack-incus in order to incus image import.

I had done that as well. My goal is to do the bulk of the image creation work only once, then import the image in two flavours, if possible: Once for containers, which I thought that ‘pack-lxc’ step was for, and once for VMs, which is where I wanted to use the ‘pack-incus’ step. But your statement suggests that I have a big misunderstanding here?

Oh, you put first the meta and then the rootfs.

Usage:
  incus image import <tarball>|<directory>|<URL> [<rootfs tarball>] [<remote>:] [key=value...] [flags]

I think that whether an image is for containers or a VM, is decided in the yaml configuration file.

I think that pack-lxc is used for LXC container images and pack-incus for Incus images (containers or VMs).

I have tried both orders, but with the exact same error message. Just saying - I would have expected incus to react differently if the order of arguments were swapped, and/or try with them swapped, so the order on the command line would not matter.