You are not logged in.

#1 2025-12-15 16:53:25

Arvigeus
Member
Registered: 2013-11-29
Posts: 23

mkosi + Arch: pacman cachedir error during image build

I am trying to build a minimal Arch Linux image using mkosi, following mkosi’s documented Arch support.

mkosi consistently fails at the very first pacman invocation with:

    error: 'failed to resolve path '/var/cache/pacman/pkg' passed to '--cachedir': No such file or directory
    "pacman --root=/buildroot --logfile=/dev/null --dbpath=/var/lib/pacman \
     --cachedir=/var/cache/pacman/mkosi \
     --cachedir=/var/cache/pacman/pkg \
     --hookdir=/buildroot/etc/pacman.d/hooks \
     --arch x86_64 --noconfirm --sync --refresh"

Notes / observations:

- `/var/cache/pacman/pkg` exists on the host:
 
      $ ls -ld /var/cache/pacman/pkg
      drwxr-xr-x 1 - root 15 Dec 18:19 /var/cache/pacman/pkg/

- The error persists even if:
  - the directory exists on the host
  - the directory exists inside the image root
  - the directory is pre-created via mkosi.extra-tree
  - mkosi hooks are used

Minimal mkosi.conf used:

```
    [Distribution]
    Distribution=arch

    [Output]
    Format=directory

    [Content]
    Packages=base linux systemd
    Bootable=yes

    [Build]
    Environment=arch
```

Offline

#2 2025-12-15 20:44:43

swsnr
Member
Registered: 2024-01-21
Posts: 26

Re: mkosi + Arch: pacman cachedir error during image build

Offline

#3 2025-12-16 05:36:20

Arvigeus
Member
Registered: 2013-11-29
Posts: 23

Re: mkosi + Arch: pacman cachedir error during image build

Thanks a lot! I picked a great time to try new tech, hehe.

Offline

#4 2025-12-20 13:18:16

swsnr
Member
Registered: 2024-01-21
Posts: 26

Re: mkosi + Arch: pacman cachedir error during image build

Offline

#5 2025-12-20 13:30:46

swsnr
Member
Registered: 2024-01-21
Posts: 26

Re: mkosi + Arch: pacman cachedir error during image build

Meanwhile you can work around this by creating "mkosi.pkgcache/cache/pacman/pkg" alongside your "mkosi.conf" (might require mkosi v26).  This creates the missing cache directory.

Offline

#6 2025-12-20 21:44:36

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,619
Website

Re: mkosi + Arch: pacman cachedir error during image build

Hadn't the fix for this been in the repos for a week now?

Edit:  there is still an issue with setting the cachedir on the command-line

Offline

#7 2025-12-21 07:50:29

swsnr
Member
Registered: 2024-01-21
Posts: 26

Re: mkosi + Arch: pacman cachedir error during image build

The issue is fixed on mkosi main, so if you install mkosi from git your images should build again.

Offline

Board footer

Powered by FluxBB