天天看點

執行vagrant報錯Vagrant failed to initialize at a very early stage: Installed version: N/A的解決方法

Windows 10環境,vagrant 安裝完成之後執行vagrant version有如下報錯

C:\Users\Administrator>vagrant version
Vagrant failed to initialize at a very early stage:

The version of powershell currently installed on this host is less than
the required minimum version. Please upgrade the installed version of
powershell to the minimum required version and run the command again.

  Installed version: N/A
  Minimum required version: 3
           

這裡提示powershell 的版本“Installed version: N/A”,也就是找不到powershell

其實powershell是已經安裝了的,見下:

Windows PowerShell
版權所有 (C) Microsoft Corporation。保留所有權利。

嘗試新的跨平台 PowerShell https://aka.ms/pscore6

PS C:\Users\Administrator> $PSVersionTable;

Name                           Value
----                           -----
PSVersion                      5.1.19041.1023
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1023
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
           

解決方法:開始-運作-sysdm.cpl-系統屬性-進階-環境變量-系統變量-找到名為PATH的系統變量-點選編輯-新加如下内容C:\Windows\System32\WindowsPowerShell\v1.0

然後退出cmd,再重新打開一個cmd,重新運作vagrant version即可

C:\Users\Administrator>vagrant version
Installed Version: 2.2.16
Latest Version: 2.2.16

You're running an up-to-date version of Vagrant!