New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Vagrant up" hangs on windows 7. Due to powershell? #8783

Closed
daffy1234 opened this Issue Jul 14, 2017 · 44 comments

Comments

Projects
None yet
@daffy1234

daffy1234 commented Jul 14, 2017

Please note that the Vagrant issue tracker is reserved for bug reports and
enhancements. For general usage questions, please use the Vagrant mailing list:
https://groups.google.com/forum/#!forum/vagrant-up. Thank you!

Vagrant version

Vagrant 1.9.7

Host operating system

Windows 7 Professional

Guest operating system

Ubuntu Server 14.04 ("ubuntu/trusty64" box)

Vagrantfile

Comments were removed.

$infoScript = <<SCRIPT
  echo 'IP-addresses of the vm ...'
  ifconfig
SCRIPT

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.network "public_network"
  config.vm.synced_folder "www", "/var/www"
  config.vm.synced_folder "phpconfig", "/etc/php5/apache2"
  config.vm.provision "shell", inline: <<-SHELL
    apt-get update
    apt-get install -y apache2 php5 libapache2-mod-php5
	sudo /etc/init.d/apache2 restart
  SHELL
  config.vm.provision "shell", inline: $infoScript,
      run: "always"
end

Debug output

https://gist.github.com/daffy1234/373f51a56ba183b886d045da99643011

Expected behavior

The machine should be provisioned and come up successfully.

Actual behavior

After the initial "vagrant up" command, absolutely no output is produced. vagrant.exe seems to open ruby.exe and powershell.exe. Killing powershell.exe twice is a workaround, and it gets the machine provisioned and booting normally. This issue does not occur after the machine has successfully booted at least once.

Steps to reproduce

  1. "vagrant up" on a brand new machine.
@daffy1234

This comment has been minimized.

daffy1234 commented Jul 14, 2017

Downgrading to Vagrant 1.9.6 is another workaround.

@ikus060

This comment has been minimized.

ikus060 commented Jul 14, 2017

I've hit the same issue on a fresh Windows 7 install with Vagrant 1.9.7.

@marcuslang

This comment has been minimized.

marcuslang commented Jul 17, 2017

Same here. It hangs here:

INFO subprocess: Starting process: ["C:\WINDOWS\System32\WindowsPowerShell\v1.0\/powershell.EXE", "-NoLogo", "-NoProfile", "-NonInteractive", "-
ExecutionPolicy", "Bypass", "-Command", "(new-object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurren
t())).IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)"]
INFO subprocess: Command not in installer, restoring original environment...
DEBUG subprocess: Selecting on IO
DEBUG subprocess: stdout: True

@ferrarimarco

This comment has been minimized.

ferrarimarco commented Jul 18, 2017

Same issue on Windows 7 x64, even running vagrant status

@bbkane

This comment has been minimized.

bbkane commented Jul 18, 2017

I have this issue as well.

@markehb

This comment has been minimized.

markehb commented Jul 19, 2017

Same here, going back to 1.9.6 resolved for me as well.

@rashidkukkady

This comment has been minimized.

rashidkukkady commented Jul 24, 2017

I have similar issue... have not tried vagrant 1.9.6 as yet. Will do and update

@sd1ver

This comment has been minimized.

sd1ver commented Jul 25, 2017

I've got the same issue.
The last message with --debug key is like the posted above:
DEBUG subprocess: stdout: False

@klangborste

This comment has been minimized.

klangborste commented Jul 28, 2017

Also for me the same issue:

vagrant up --debug
....last 3 lines from debuggin output:
INFO subprocess: Command not in installer, restoring original environment...
DEBUG subprocess: Selecting on IO
DEBUG subprocess: stdout: True

@badhop

This comment has been minimized.

badhop commented Jul 28, 2017

Have the same problem.

@edwardmlyte

This comment has been minimized.

edwardmlyte commented Aug 1, 2017

As has been commented on #8777, killing the powershell.exe process allows vagrant to continue, should you really NEED the latest version for some other reason.

@bozemojmaciej

This comment has been minimized.

bozemojmaciej commented Aug 1, 2017

Hello, same issue appeared today. Fix that worked for me was to update Windows PowerShell (was 2009). Now it is 2016 version and Vagrant works perfect. You can update it by installing WMF: https://msdn.microsoft.com/en-us/powershell/mt173057.aspx

@pscheit

This comment has been minimized.

pscheit commented Aug 1, 2017

upgrading powershell helps (install WMF 5)
you commented half an hour earlier :D

@syagawa

This comment has been minimized.

syagawa commented Aug 2, 2017

Update Windows Powershell to ver 5, the problem was solved.

Vagrant: Vagrant 1.9.7
Host OS: Windows 7 Professional 64bit
Guest OS: Ubuntu Server 14.04 ("ubuntu/trusty64" box)

@ikus060

This comment has been minimized.

ikus060 commented Aug 2, 2017

Upgrading powershell cannot be a final fix for this bug. I recommend to show a warning in vagrant, asking the user to upgrade power shell...

@dfad1ripe

This comment has been minimized.

dfad1ripe commented Aug 2, 2017

WMF 5.1 + .NET 4.6.1 works for me too on Win 7 SP1. Even with that, after launching 'vagrant up', it freezes for ~20 sec, while powershell.exe eats up to 50% of i5 CPU resources. I don't remember such behavior on earlier versions.

@mikeyo241

This comment has been minimized.

mikeyo241 commented Aug 3, 2017

I had the same problem running vagrant up for "ubuntu/trusty64" it would hang on:
DEBUG subprocess: Selecting on IO
DEBUG subprocess: stdout: True.
I installed WMF like @bozemojmaciej suggested and the problem is fixed!!

@ashokvaddevalli

This comment has been minimized.

ashokvaddevalli commented Aug 7, 2017

I am also facing same issue on using Vagrant 1.9.6 version.

INFO subprocess: Starting process: ["C:\Windows\System32\WindowsPowerShell\v1.0\/powershell.EXE", "-NoLogo", "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", "(new-object System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator)"]
INFO subprocess: Command not in installer, restoring original environment...
DEBUG subprocess: Selecting on IO
DEBUG subprocess: stdout: True

@zafaralam

This comment has been minimized.

zafaralam commented Aug 8, 2017

Had the same issue on my windows 7 machine.

Updated Windows Poweshell to version 5 and all works now.

Thanks a lot.

@ashokvaddevalli

This comment has been minimized.

ashokvaddevalli commented Aug 8, 2017

Updating Powershell on Host Machine or guest VM?

@pscheit

This comment has been minimized.

pscheit commented Aug 8, 2017

host

@ashokvaddevalli

This comment has been minimized.

ashokvaddevalli commented Aug 8, 2017

Thanks @pscheit

I have Updated Windows Poweshell to version 5 on host machine(Vagrant installed machine), now it was working now.

But I am getting another issue,

INFO synced_folders: Synced Folder Implementation: smb
INFO synced_folders: - /vagrant: . => /vagrant
INFO synced_folders: Invoking synced folder prepare for: smb
INFO interface: output: Preparing SMB shared folders...
INFO interface: output: ==> default: Preparing SMB shared folders...
INFO interface: detail: You will be asked for the username and password to use for the SMB
folders shortly. Please use the proper username/password of your
Windows account.

INFO interface: detail: default: You will be asked for the username and password to use for the SMB
default: folders shortly. Please use the proper username/password of your
default: Windows account.
default:
INFO interface: ask: Username:
INFO interface: ask: default: Username:

@wiltaylor

This comment has been minimized.

wiltaylor commented Aug 8, 2017

Prompting you for Samba folder credentials is normal. It is asking for an account on your host to connect to. You can put the credentials in the vagrant file but it isn't very secure to do so.

One work around I have is I store credentials in some environment variables and pass those into the vagrantfile. I set the environment variables when I open powershell to help keep them only to my vagrant session.

Example:

Vagrant.configure("2") do |config|
  config.vm.box = "Windows2012R2"
  config.vm.network "public_network", :bridge => "NAT
  config.vm.synced_folder ".", "/vagrant", type: "smb", smb_username: ENV["smb_username"], smb_password: ENV["smb_password"]
  end
end
@Bilge

This comment has been minimized.

Bilge commented Aug 8, 2017

Confirm same hanging issue on Win 7 x64 with Vagrant 1.9.7.

@maheshbisen

This comment has been minimized.

maheshbisen commented Aug 9, 2017

Its working for me after updating windows powershell.

Vagrant: Vagrant 1.9.7
Host OS: Windows 7 Professional 32bit
Guest OS: Ubuntu Server 14.04 ("ubuntu/trusty32" box)

@ashokvaddevalli

This comment has been minimized.

ashokvaddevalli commented Aug 9, 2017

Thanks @wiltaylor

My issue is resolved.

@kylerdmoore

This comment has been minimized.

kylerdmoore commented Aug 25, 2017

Upgrading PowerShell fixed for me. Was running PowerShell 2. Upgraded to PowerShell 5 with the Windows Management Framework (WMF) 5.1 and vagrant no longer got hung up at "vagrant up" command.

Vagrant 1.9.8
Windows 7 Professional 64bit
VirtualBox 5.1.26
Using trusty64 as host vm

Here's the guide I used to upgrade PowerShell. The frameworks in this post are outdated but the rest is correct. http://mikefrobbins.com/2015/01/08/how-to-check-the-powershell-version-and-install-a-new-version/

@chrisroberts

This comment has been minimized.

Member

chrisroberts commented Aug 28, 2017

Upgrading powershell should resolve the issue. The latest release (1.9.8) includes this PR #8839 that checks the powershell version and raises an error if the minimum is not satisfied. Cheers!

@MorganGeek

This comment has been minimized.

MorganGeek commented Aug 31, 2017

@chrisroberts even on 1.9.8 I still need to kill powershell.exe in order to see the warning...

@elconde

This comment has been minimized.

elconde commented Sep 12, 2017

@chrisroberts On 2.0.0 I also need to kill powershell.exe to see this warning.

@elconde

This comment has been minimized.

@hummal

This comment has been minimized.

hummal commented Sep 18, 2017

@chrisroberts I have 2.0.0 installed and I don't see any warning. Not even if I kill the process. Updating PS to v5 helps

@timmjd

This comment has been minimized.

timmjd commented Sep 29, 2017

Last working version for Windows 7 seems to be 1.9.5. Haven't tested 1.9.6 yet, but its broken since 1.9.7.

@StalkAlex

This comment has been minimized.

StalkAlex commented Oct 3, 2017

@chrisroberts your PR is not doing what you described. There wasn't any exceptions/warnings on last version 2.0.0, windows 7, getting here is what help me to solve the problem.

@dmz9

This comment has been minimized.

dmz9 commented Oct 10, 2017

here is a faster and easier way of applying the workaround about installing new version of powershell.
do at your own risk, worked for me (not having any critical powershell-based startup scripts)

  1. install separate powershell 6 beta (atm). here is the git repo https://github.com/PowerShell/PowerShell/releases
    for win7 x64 i picked .msi version
  2. by default it gets installed to C:\Program Files\PowerShell\6.0.0-beta.8 (my version)
  3. rename old C:\Windows\System32\WindowsPowerShell\v1.0 to _v1.0 (or whatever) to have rollback just in case
  4. copy C:\Program Files\PowerShell\6.0.0-beta.8* into newly created C:\Windows\System32\WindowsPowerShell\v1.0*
  5. reboot (optional)
  6. profit

vagrant loaded ok

@anthony-o

This comment has been minimized.

anthony-o commented Nov 27, 2017

With latest v6.0.0-rc, @dmz9 technic failed: vagrant up ends in error with:

Failed to locate the powershell executable on the available PATH. Please
ensure powershell is installed and available on the local PATH, then
run the command again.

And indeed, there is no powershell.exe but a pwsh.exe in C:\Program Files\PowerShell\6.0.0-rc. If I duplicate pwsh.exe to powershell.exe in C:\Windows\System32\WindowsPowerShell\v1.0 after step 4, then vagrant up fails with:

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

Finally, after following a solution in Stackoverflow, it finally worked: I installed .NET Framework 4.5.

@jcarey987

This comment has been minimized.

jcarey987 commented Dec 7, 2017

So i updated powershell, and i type vagrant ssh into my terminal, which logs me into my machine. while i am logged in, the command prompt disappears. anyone else seeing this?

@robertluwang

This comment has been minimized.

robertluwang commented Dec 30, 2017

It is very interesting, vagrant up just hanging there forever, only saw exception when I killed all powershell process,

ERROR vagrant: #<Vagrant::Errors::PowerShellInvalidVersion: 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>

checked my powershell is 2,

$PSVersionTable.PSVersion

Solved the issue by upgraded WMF to 4.0.

@MlleDelphine

This comment has been minimized.

MlleDelphine commented Mar 23, 2018

I am facing the same issue now.
Today, I've up my Vagrant VMs.
I've halted them.
I've destroyed one VM and try a "vagrant up" to recreate.

Failed to locate the powershell executable on the available PATH. Please
ensure powershell is installed and available on the local PATH, then
run the command again.

Vagrant version : 2.0.1
Windows version : 10 Pro, 64bits
PowerShell version : 5.1.16299.98

@navigatrum

This comment has been minimized.

navigatrum commented Mar 28, 2018

Same problem.
Updated from Vagrant 1.8.5 to Vagrant 2, new Vagrantfile worked, but on vagrant up:

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

Vagrant Version 2.0.3
Windows version: 10 Home, 64bits
PowerShell version: 5.1.16299.251

@briancain

This comment has been minimized.

Member

briancain commented Mar 28, 2018

Hi @navigatrum - this issue has already been reported in #9629. Thanks!

@ultrasamad

This comment has been minimized.

ultrasamad commented Apr 9, 2018

Restarting the pc in case of windows after adding the box before running vagrant up did a fix for me.

@alhaponyfarag

This comment has been minimized.

alhaponyfarag commented May 10, 2018

In my case, this issue was solved by updating powershell and .Net framework

@nunoxavier

This comment has been minimized.

nunoxavier commented Nov 29, 2018

Fixed this by adding "%SYSTEMROOT%\System32\WindowsPowerShell\v1.0" to the environment PATH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment