Apple installer command is returning error when run from a binary with Full Disk Access on Sonoma

I have a go binary that runs from /usr/local/bin. This application has the ability to update itself by downloading the latest .pkg from our company and running it with the installer command. Our application has also been granted Full Disk Access.

The command that is run by our application looks like this: installer -pkg /tmp/ourInstaller.pkg -target /. This command works from a terminal (when run with sudo and when the terminal has Full Disk Access). It also has been working on all MacOS version above 10.15.

With MacOS Sonoma on the M platform (not on an Intel device), this command has started to give the following error: installer: Package name is Agent Installer\ninstaller: Upgrading at base path /\ninstaller: The upgrade failed. (The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance. An unexpected error occurred while moving files to the final destination.)\n.

This is an error we see when our application is not granted Full Disk Access, but as mentioned, our application has been granted Full Disk Access. Also, the installation appears to complete successfully, meaning the files are moved to the correct place, but the installation still errors.

It seems to be erroring while copying the new binary to /usr/local/bin. In fact, it cannot copy any file to /usr/local/bin without erroring, even a simple text file. This leads me to believe that it may be erroring on trying to rollback the previous install, but since the binary has Full Disk Access, it is failing to remove the old binary (rightfully so) and so the installer errors.

I just want to reiterate that this has always worked, and only with Sonoma on M architecture machines (M1 and M2) has this started erroring.

Some additional info: I have found that it is removing Full Disk Access completely. Before I was leaving the versions the same for all .pkgs when building, and now I am incrementing by one, and I see the same error but Full Disk Access is actually getting removed. It is truly removing full disk access, but I'm not sure why, it should be a standard installation which should not cause it to be removed.

I've also tried installing the binary to a separate location and changing the .pkg identifier for that step, and it still removes Full Disk Access, suggesting maybe something to do with a rollback of the previous package?

Apple installer command is returning error when run from a binary with Full Disk Access on Sonoma
 
 
Q