question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
p120ph37commented, Jun 19, 2017

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.

0reactions
hawx1993commented, Aug 29, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating a MacOS .pkg installer that does not require admin ...
I've been trying to create a .pkg installer that doesn't require the end-user to have elevated privileges to use. It's gotten to a...
Read more >
Install .PKG without Admin password (macOS) - YouTube
How to install a . pkg package file without Administrator password on macOSThis video tutorial will show you the step-by-step procedure on ...
Read more >
Is it possible the create a pkg that doesn't require root access ...
There's an option in PackageMaker. You can still install into /Applications too, but the user would need to be in the admin group...
Read more >
Installing R without administrator privileges - RPubs
The easiest way that I have found to install R and RStudio under Windows, when you don't have admin privileges, is to create...
Read more >
How can I create a windows installer MSI that does not require ...
Hello, this question helped me create an MSI file ... how do i create an installer that doesn't require admin access? vs-generalvs-msbuild.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found