安装 chocolatey 时警告该如何解决?

安装 chocolatey 时警告该如何解决?

当我安装 chocolatey 时,出现如下错误:

在此处输入图片描述

...

WARNING: It's very likely you will need to close and reopen your shell
  before you can use choco.
...

WARNING: You can safely ignore errors related to missing log files when
  upgrading from a version of Chocolatey less than 0.9.9.
  'Batch file could not be found' is also safe to ignore.
  'The system cannot find the file specified' - also safe.
WARNING: Not setting tab completion: Profile file does not exist at
'C:\Users\Chelsea
\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1'.

...

我该如何解决这个错误?

答案1

以下是 Tab 键补全警告的解决方案:

  1. 打开 PowerShell 会话并运行:notepad $profile这将在记事本中打开配置文件。

  2. 将以下代码复制并粘贴到记事本中并保存文件:

# Chocolatey profile
$ChocolateyProfile = "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
if (Test-Path($ChocolateyProfile)) {
  Import-Module "$ChocolateyProfile"
}
  1. 重启 PowerShell

来源:https://docs.chocolatey.org/en-us/troubleshooting#why-does-choco-tab-not-work-for-me

答案2

我自己也遇到过这个警告。出现此警告的原因是您的 Windows 用户没有现有的 PowerShell 配置文件。

要创建配置文件,请打开 PowerShell 会话并输入:

if (!(Test-Path -Path $PROFILE)) {
  New-Item -ItemType File -Path $PROFILE -Force
}

我从以下网址提取了上述代码微软的文档。如果您有兴趣,该页面涵盖了更多有关个人资料的内容。

相关内容