Troubleshooting Apple’s PackageMaker can be a hassle. Especially when you’re getting generic errors, such as
The Installer encountered an error that caused the installation to fail. Contact the software manufacturer for assistance
Recently, I ran into an issue with compiling packages on a Mac that was bound to an Active Directory environment. When I was compiling the package and sending it to another team to test it out in another environment, it was failing on their machine but working fine on mine. Why? Well, after looking into the logs (Installer -> Window -> Installer Log / Command+L) I saw a line that said
Installer: install:didFailWithError:Error Domain=PKInstallErrorDomain Code=112 "An error occurred while running scripts from the package “Name-of-package.pkg”." UserInfo={NSFilePath=./preinstall, NSURL=file://localhost/Users/user/path/to/package/name-of-package.pkg#package-shortname.pkg, PKInstallPackageIdentifier=com.muhcompany.name-of-package.pkg.pkg, NSLocalizedDescription=An error occurred while running scripts from the package “name-of-package.pkg
What this initially told me was that the system was having trouble executing the scripts after expanding the package on the remote Mac. Some forums reported success by compressing the PKG with ZIP or TAR, others said that you needed to use pkgutil
to expand the package manually, make the script contents executable, then flatten it. But when I inspected the scripts, they already had the executable bit set. So I figured, “Maybe I need to chown
the files as root:staff
or something?” That didn’t work either.
Turns out that I had to do two things.
- Copy the package to a Mac that wasn’t bound to AD, expand the package,
chown
it asroot:staff
with group and other permissions set to+rx
for each directory and script. - Make sure the scripts don’t exit with a code of
1
, or else it will throw the generic error “The Installer encountered an error”, etc, etc.
You may not have to copy your package to a non-bound Mac, as the one I was using had special extra-tight security specifications, but it’s what seemed to have fixed the problem for me.