Re: `pkg autoremove` uninstalls pkg itself

From: Dag-Erling_Smørgrav <des_at_FreeBSD.org>
Date: Thu, 04 Apr 2024 16:17:04 UTC
Yasuhiro Kimura <yasu@FreeBSD.org> writes:
> 1. Make clean install of 14.0-RELEASE amd64.
> 2. Login as root
> 3. pkg install git-tiny

Since you didn't already have pkg, it was bootstrapped here, and marked
it as non-automatic.

> 4. cd /usr/ports
> 5. git clone https://git.freebsd.org/ports.git .
> 6. pkg delete -afy

This deleted pkg even though it was marked as non-automatic, because
that's what the -f flag does, cf. pkg-delete(8).

> 7. cd security/sudo (Probably any other ports are OK expect ports-mgmt/pkg)
> 8. make install

This installed pkg as a build dependency of sudo, and marked it as
automatic.

> 9. pkg-static autoremove -y

This removed pkg because it was marked as automatic and had no
dependents.

> Then is it expected behavior?

Yes, it did exactly what you asked it to do.

DES
-- 
Dag-Erling Smørgrav - des@FreeBSD.org