Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no way to build pkg that doesn't require admin install #1685

Closed
p120ph37 opened this issue Jun 16, 2017 · 5 comments
Closed

no way to build pkg that doesn't require admin install #1685

p120ph37 opened this issue Jun 16, 2017 · 5 comments

Comments

@p120ph37
Copy link
Contributor

  • 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.

@develar
Copy link
Member

develar commented Jun 17, 2017

You are right. Fixed.
screen shot 2017-06-17 at 20 42 26

@develar
Copy link
Member

develar commented Jun 17, 2017

Thanks for clear report — decided to fix but not move to backlog :)

@develar develar closed this as completed Jun 18, 2017
@p120ph37
Copy link
Contributor Author

Hmmm, it seems to be only halfway working...

Looks like you need to remove the customLocation="/Applications" attribute in the Distribution 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 the admin group, this succeeds without an elevation prompt (install ends up owned by myuser:admin rather than root: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 the Distribution file, and then pkgutil -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:

installer -pkg myapp-1.0.0.pkg -target CurrentUserHomeDirectory

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
Copy link
Member

develar commented Jun 20, 2017

@p120ph37 Thanks, fixed in 19.6.0.

@hawx1993
Copy link

@develar can u tell me how to config so that I can install pkg file not need to input PWD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants