Skip to content

Instantly share code, notes, and snippets.

@tknerr
Created May 5, 2015 12:34
Show Gist options
  • Select an option

  • Save tknerr/ca2978b9eb2721e45da4 to your computer and use it in GitHub Desktop.

Select an option

Save tknerr/ca2978b9eb2721e45da4 to your computer and use it in GitHub Desktop.
Given the below Vagrantfile the vagrant up process keeps hanging / does not return. Might have to do with the fact that `vagrant ssh -c "echo foo"` does not work either but drops us into an interactive powershell
EBUG ssh: Checking whether SSH is ready...
DEBUG ssh: Re-using SSH connection.
INFO ssh: SSH is ready!
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: (sudo=false)
DEBUG ssh: Exit status: 0
DEBUG ssh: stderr: 'export' is not recognized as an internal or external command,
operable program or batch file.
DEBUG ssh: stdout: Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\vagrant>
C:\Users\vagrant>C:\Users\vagrant>
DEBUG guest: Searching for cap: mount_virtualbox_shared_folder
DEBUG guest: Checking in: windows
DEBUG guest: Found cap: mount_virtualbox_shared_folder in windows
INFO guest: Execute capability: mount_virtualbox_shared_folder [#<Vagrant::Machine: default (VagrantPlugins::ProviderVirtualBox::Provider)>, "vagrant", "/vagrant", {:guestpath=>"/vagrant", :hostpath=>"C:/Repos/_github/bills-kitchen/target/build/repo/windows-examples/basics", :disabled=>false, :owner=>"vagrant", :group=>"vagrant"}] (windows)
DEBUG ssh: Re-using SSH connection.
INFO ssh: Execute: function Test-ReparsePoint([string]$path) {
$file = Get-Item $path -Force -ea 0
return [bool]($file.Attributes -band [IO.FileAttributes]::ReparsePoint)
}
$MountPoint = [System.IO.Path]::GetFullPath("/vagrant")
$ShareName = "vagrant"
$VmProviderUncPath = "\\vboxsrv\vagrant"
# https://github.com/BIAINC/vagrant-windows/issues/4
# Not sure why this works, but it does.
& net use $ShareName 2>&1 | Out-Null
Write-Debug "Attempting to mount $ShareName to $MountPoint"
if( (Test-Path "$MountPoint") -and (Test-ReparsePoint "$MountPoint") )
{
Write-Debug "Junction already exists, so I will delete it"
# Powershell refuses to delete junctions, oh well use cmd
cmd /c rd "$MountPoint"
if ( $LASTEXITCODE -ne 0 )
{
Write-Error "Failed to delete symbolic link at $MountPoint"
exit 1
}
}
elseif(Test-Path $MountPoint)
{
Write-Debug "Mount point already exists and is not a symbolic link"
exit 1
}
$BaseDirectory = [System.IO.Path]::GetDirectoryName($MountPoint)
if (-not (Test-Path $BaseDirectory))
{
Write-Debug "Creating parent directory for mount point $BaseDirectory"
New-Item $BaseDirectory -Type Directory -Force | Out-Null
}
cmd /c mklink /D "$MountPoint" "$VmProviderUncPath" | out-null
if ( $LASTEXITCODE -ne 0 )
{
exit 1
}
(sudo=false)
DEBUG ssh: stdout: Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
DEBUG ssh: Sending SSH keep-alive...
Vagrant.configure(2) do |config|
config.vm.box = "boxcutter/eval-win7x86-enterprise-nocm"
# tell the VM to explictly use ssh and not replace keys
config.vm.communicator = :ssh
config.ssh.insert_key = false
config.vm.provision "shell", inline: "echo hello from inline"
end
@mikhelev

Copy link
Copy Markdown

Hello! Do you have answer? How to win it?

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