修改 chocolatey 安装路径
最新版本的 chocolatey
的默认安装路径是:
C:\ProgramData\Chocolatey
如何修改为自己的路径呢?
在 系统环境变量 中增加 ChocolateyInstall
:
d:\chocolatey
替换成你自己的路径

然后打开 cmd 窗口,执行如下命令:
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "(iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))) >$null 2>&1" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
命令取自 chocolatey github
安装完成之后,chocolatey
会自动将路径添加到 用户环境变量 中。

portable 便携式文件的解压路径
portable package
的默认解压路径:
d:\chocolatey\lib
d:\chocolatey
是我上面定制的chocolatey
的安装路径。
似乎不能修改解压路径,还没弄懂,chocolatey
有一段解释:
A portable application is something that doesn't require a native installer to use. In other words, it is not “installed” on your system (where you can go to uninstall in the control panel). It also requires no administrative access for the package install.
Portable applications end up in the %ChocolateyInstall%/lib (i. e. C:\ProgramData\Chocolatey\lib) folder yes, but they get a "shim" to put them on the path of the machine. This behavior is very much to how Chocolatey works and is not configurable (the directory). Where the portable apps end up is still going to be %ChocolateyInstall%/lib no matter where you move the directory, unless a package itself unpacks the portable app elsewhere (as in the case of git-tfs).
对于 portable
类型的安装文件,chocolatey
会在 d:\chocolatey\bin
下面添加执行可以执行文件的快捷方式,所以我们需要将此目录添加到环境变量中,以方便通过运行命令快速启动程序。
installable 可安装文件的安装路径
portable 默认安装路径是 $env:ChocolateyInstall\lib
,但有些软件可能会有各种各样的路径,这取决于软件的发布者。
一些包是安装在 ChocolateyInstall\lib
,一些特定的基于 windows installers (.msi files)
的软件是安装在原始安装程序的默认路径(绝大部分在 Program Files
)。
还有一些包,你可以定制安装路径,通过添加环境变量 ChocolateyToolsLocation
指定安装路径,如果这个环境变量不存在,它将被安装在 c:\tools
,以包名作为子目录。
以后会改为
ChocolateyToolsRoot
,所以最好设置这两个环境变量,以备有迹可寻。
# 环境变量安装路径
< chocolatey-0.9.10: $env:ChocolateyBinRoot
>=chocolatey-0.9.10: $env:ChocolateyToolsLocation
对于带有 install
后缀的安装软件,可以通过如下指令指定安装路径:
choco install notepadplusplus.install --ia "'/D=d:\mytools\notepad++'" -y
相当于将参数 '/D=d:\mytools\notepad++'
传递给本地安装包。
网友评论