no way to build pkg that doesn't require admin install
See original GitHub issue- Version: 18.6.2
- Target: pkg
The inner pkg file is generated with <pkg-info auth="root" />
inside its PackageInfo
. This causes the resultant outer product installer to prompt for elevated privileges in order to complete installation.
If the default installation location is /Applications
, that makes sense since it is not generally user-writable, however installation to ~/Applications
should be possible without elevated permission.
This also has the side-effect that running installer -pkg myapp-1.0.0.pkg -target /
will fail with the message installer: Must be run as root to install this package.
if not run under sudo
.
I’d like to see some package.json
options like the NSIS target has (perMachine
), which can enable non-admin install to the user-level directory. I’m not sure exactly how to suppress the auth="root"
setting in PackageInfo
- it might require an expand/flatten of the pkg file using pkgutil
to edit that file, as I can’t seem to find anywhere in the distribution.xml
that would control that.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
Hmmm, it seems to be only halfway working…
Looks like you need to remove the
customLocation="/Applications"
attribute in theDistribution
file in order for the installer to automatically use~/Applications
when per-user is selected. With the attribute present, even if per-user is selected, the installer tries to install explicitly into/Applications
. If the current user is in theadmin
group, this succeeds without an elevation prompt (install ends up owned bymyuser:admin
rather thanroot:wheel
as is the case when installed for “all users” with elevation), but the application ends up in the wrong location (/Applications
, not~/Applications
), and available to all users (drwxr-xr-x
). If the user is not an admin user, then installation fails with a permissions error, since/Applications
is not writable for non-admin.I was able to use
pkgutil -expand
, edit theDistribution
file, and thenpkgutil -flatten
to produce a corrected.pkg
, which behaves as expected, so this seems to be the only lingering issue.Oh, and in case anyone else reads this comment, the proper way to invoke the
installer
command as non-root for a per-user install is:This was really poorly documented - many places incorrectly say you can use
-target ~
or-target $USER
or something like that, which is very much not true.Note: be sure to
rm -rf dist/mac
before running the pkg install, otherwise it will detect that folder as an existing installation and try to upgrade it instead of installing where expected.@develar can u tell me how to config so that I can install pkg file not need to input PWD