pkgbase: build KERNEL with WITH_MODULES=... failure: chroot: /bin/sh: No such file or directory

From: FreeBSD User <freebsd_at_walstatt-de.de>
Date: Fri, 24 Apr 2026 11:41:00 UTC
Building for 15-STABLE kernel packages (aka pkgbase) without any
additional modules works fine, but as it is with the traditional
(working) way with a locally populated /usr/src and /usr/ports setting
appropriate variables in /etc/src.conf, i.e. WITH_MODULES=...
preventing prerequisite drm modules to be in sync, this specific
intention doesn't seem to work with pkgbase.

While hosting several flavors/versions of FreeBSD (15.0-RELENG,
15-STABLE, CURRENT), source trees are at different places in the tree.
I do not wish to populate this mail with all the details, I'd like to
state, that building kernel packages without involving the ports tree
works fine, and doesn't the moment WITH_MODULES= is involved.

I use a custom make.conf with the lines
PORTSDIR=
DISTDIR=
WRKDIRPREFIX=/tmp

PORTSDIR points to a poudriere populated directory, up to date,
working. DISTDIR to the appropriate folder holding all tarballs
necessary.

Something is missing I couldn't find in the docs I've read. I'm hit
with the error shown below, x11/nvidia-driver is the first module in
the list of modules:

PORTS_MODULES+=         x11/nvidia-driver
PORTS_MODULES+=         graphics/libdrm
PORTS_MODULES+=         graphics/drm-kmod
PORTS_MODULES+=         graphics/drm-latest-kmod
PORTS_MODULES+=         graphics/drm-66-kmod
PORTS_MODULES+=         graphics/drm-61-kmod
PORTS_MODULES+=         graphics/drm-515-kmod
PORTS_MODULES+=         graphics/drm-510-kmod
PORTS_MODULES+=         graphics/drm-kmod
PORTS_MODULES+=         sysutils/cpu-microcode
PORTS_MODULES+=         sysutils/cpu-microcode-rc
PORTS_MODULES+=         sysutils/cpu-microcode-amd
PORTS_MODULES+=         sysutils/cpu-microcode-intel


[...]
===> Ports module x11/nvidia-driver (install)
port=x11/nvidia-driver; flavor=${port#*@}; port=${port%@*};
flavor=${flavor%${port}};  cd /pool/poudriere/ports/head/${port};  env
-u CC  -u CXX  -u CPP  -u MAKESYSPATH  -u MK_AUTO_OBJ  -u MAKEOBJDIR
MAKEFLAGS="-D NO_ROOT -D NO_ROOT
DESTDIR=/pool/sources/15-STABLE/obj/pool/sources/15-STABLE/src/amd64.amd64/kernelstage/./kernel.GENERIC
DISTBASE=/kernel.GENERIC DISTDIR=. KERNCONF=GENERIC\ GENERIC
KERNCONFDIR=/usr/local/etc/config/15-STABLE/amd64/kernel_conf/
KERNEL=kernel.GENERIC
METALOG=/pool/sources/15-STABLE/obj/pool/sources/15-STABLE/src/amd64.amd64/kernelstage/./kernel.GENERIC.premeta
NO_INSTALLEXTRAKERNELS=NO NO_INSTALLKERNEL=NO
PKG_VERSION=15.snap20260424103857 TARGET=amd64 TARGET_ARCH=amd64"
SYSDIR=/pool/sources/15-STABLE/src/sys
PATH=/pool/sources/15-STABLE/obj/pool/sources/15-STABLE/src/amd64.amd64/tmp/bin:/pool/sources/15-STABLE/obj/pool/sources/15-STABLE/src/amd64.amd64/tmp/usr/sbin:/pool/sources/15-STABLE/obj/pool/sources/15-STABLE/src/amd64.amd64/tmp/usr/bin:/pool/sources/15-STABLE/obj/pool/sources/15-STABLE/src/amd64.amd64/tmp/legacy/usr/sbin:/pool/sources/15-STABLE/obj/pool/sources/15-STABLE/src/amd64.amd64/tmp/legacy/usr/bin:/pool/sources/15-STABLE/obj/pool/sources/15-STABLE/src/amd64.amd64/tmp/legacy/bin:/pool/sources/15-STABLE/obj/pool/sources/15-STABLE/src/amd64.amd64/tmp/legacy/usr/libexec:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
 SRC_BASE=/pool/sources/15-STABLE/src  OSVERSION=1600015
WRKDIRPREFIX=/tmp/ make -B ${flavor:+FLAVOR=}${flavor}  deinstall
reinstall /bin/sh: 15.snap20260424103857: not found make[9]:
/pool/poudriere/ports/head/Mk/bsd.port.mk:1206: warning: Command
"15.snap20260424103857 -t 2.7.4 1.17.2" exited with status 127 ===>
Creating some important subdirectories ===> /tmp subdirectory has been
successfully created ===> /dev subdirectory has been successfully
created ===>  Starting chrooted make in
/pool/sources/15-STABLE/obj/pool/sources/15-STABLE/src/amd64.amd64/kernelstage/./kernel.GENERIC...
chroot: /bin/sh: No such file or directory ===>  Chrooted make in
/pool/sources/15-STABLE/obj/pool/sources/15-STABLE/src/amd64.amd64/kernelstage/./kernel.GENERIC
failed ===>  Cleaning up... *** Error code 1