hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.17k stars 4.43k forks source link

"vagrant up" cannot run with Hyper-V #12746

Open sesameguy opened 2 years ago

sesameguy commented 2 years ago

Hi, i'm a newbie of vagrant. I've installed the latest version(v2.2.19) & enabled Hyper-V, but the below error message is shown when run vagrant up

Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
An error occurred while executing a PowerShell script. 
This error is shown below. 
Please read the error message and see if this is a configuration error with your system. 
If it is not, then please report a bug.

Script: check_hyperv.ps1
Error:

The argument '$env:PSModulePath=$env:PSModulePath+';C:\HashiCorp\Vagrant\embedded\gems\2.2.19\gems\vagrant-2.2.19\plugins\providers\hyperv\scripts\utils'; &('C:\HashiCorp\Vagrant\embedded\gems\2.2.19\gems\vagrant-2.2.19\plugins\providers\hyperv\scripts\check_hyperv.ps1')' is not recognized as the name of a script file. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

I've tried to run $env:PSModulePath=$env:PSModulePath+';C:\HashiCorp\Vagrant\embedded\gems\2.2.19\gems\vagrant-2.2.19\plugins\providers\hyperv\scripts\utils'; &('C:\HashiCorp\Vagrant\embedded\gems\2.2.19\gems\vagrant-2.2.19\plugins\providers\hyperv\scripts\check_hyperv.ps1') only in powershell & it's no problem so i think the problem is caused by vagrant up

sesameguy commented 2 years ago

I found the problem is caused by powershell core I tried the command vagrant up in window powershell & it has no problem

Would vagrant support powershell core in the future version?

juergenpf commented 1 year ago

Looking into the ruby code that assembles the powershell command lines (... plugins/lib/vagrant/util/powershell.rb), to me the problem is located there. They assemble PATH variables with the hardcoded path delimiter ";" (Semicolon), but on POSIX-like systems like Linux or MacOS the path separator is ":" (Colon). I think the Powershell related code needs a general review for these kind of effects.