macos 如何使用终端安装 Mac 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4384409/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 07:24:12  来源:igfitidea点击:

How to install a Mac application using Terminal

cocoamacosterminalinstallpackage

提问by David

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

苹果建议在提交到 Mac 应用商店之前,使用命令测试 Mac 的安装过程

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?

我对终端陌生。这是什么意思,我该如何修复它以便我可以按照 Apple 的建议安装应用程序?

回答by Ben

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 /

回答by Moses

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