How to install a Mac application using Terminal

2019-03-08 15:46发布

Apple suggests that prior to submitting to the Mac application store, the installation process for Macs be tested using the command

sudo installer -store -pkg path-to-package -target /

I saved the application package to the desktop and then in the terminal I sent the command

sudo installer -store -pkg /User/MyName/Desktop/helloWorld.pkg -target /

From the above command I get this

installer: invalid option -
Usage: installer [-help] [-dominfo] [-volinfo] [-pkginfo] [-allow] [-dumplog]
                 [-verbose | -verboseR] [-vers] [-config] [-plist]
                 [-file <pathToFile>] [-lang <ISOLanguageCode>] [-listiso]
                 [-showChoicesXML] [-applyChoiceChangesXML <pathToFile>]
                 [-showChoicesAfterApplyingChangesXML <pathtoFile>]
                 -pkg <pathToPackage>
                 -target <[DomainKey|MountPoint|DiskIdentifier|DeviceNode|UUID]>

I am very new to the Terminal. What does this mean and how do I fix it so that I can install the application as suggested by Apple?

2条回答
戒情不戒烟
2楼-- · 2019-03-08 15:53

Probably not exactly your issue..

Do you have any spaces in your package path? You should wrap it up in double quotes to be safe, otherwise it can be taken as two separate arguments

sudo installer -store -pkg "/User/MyName/Desktop/helloWorld.pkg" -target /
查看更多
迷人小祖宗
3楼-- · 2019-03-08 16:11

To disable inputting password:

sudo visudo

Then add a new line like below and save then:

# The user can run installer as root without inputting password
yourusername ALL=(root) NOPASSWD: /usr/sbin/installer

Then you run installer without password:

sudo installer -pkg ...
查看更多
登录 后发表回答