#1104607 debhelper: Invoking "debian/rules binary" by hand triggers "dh_testroot: error: You must run this as root (or use fakeroot)."

Package:
debhelper
Source:
debhelper
Submitter:
Santiago Vila
Date:
2025-05-02 21:33:03 UTC
Severity:
normal
Tags:
#1104607#5
Date:
2025-05-02 20:44:53 UTC
From:
To:
Hello Niels et al.

Now that most packages allow building without fakeroot, I would
expect this to work:

(Using indent as an example because it has Rules-Requires-Root: no
and a very low build time)

$ apt-get source indent
$ cd indent-2.2.13
$ debian/rules build
[...]
$ debian/rules binary
dh binary
    dh_testroot
dh_testroot: error: You must run this as root (or use fakeroot).
make: *** [debian/rules:3: binary] Error 255

If I replace dh_testroot by a symlink to true, then it fails
because dh_installdocs tries to use chown.


This is strange because I don't need fakeroot at all inside
the chroot when I build the package using dpkg-buildpackage.

Not sure if my expectancy is realistic or not, maybe I'm
missing something.

Thanks.

#1104607#10
Date:
2025-05-02 21:15:32 UTC
From:
To:
Santiago Vila:

Hi,

That is correct behavior for debhelper according to the rootless spec
and the necessary support for packages that do require (fake)root, where
the builder exposes DEB_RULES_REQUIRES_ROOT to announce whether it is a
rootless builds. You (as a package builder) need to use
`dpkg-buildpackage` to invoke `debian/rules` for rootless builds.

If you (as a maintainer) for some reason need to debug some very
specific issue (etc.) where bypassing `dpkg-buildpackage` is imperative,
you can use `DEB_RULES_REQUIRES_ROOT=<value> debian/rules binary`.

Best regards,
Niels