Overview of the Issue
When run on a Windows host, the absolute path generated in Vagrantfile from synced_folder configuration property contains only single backslash characters (\) as path separators. This is not supported because Vagrantfile is a Ruby file and backslash is an escape character in Ruby
Reproduction Steps
On a Windows host, with packer, vagrant and virtualbox installed, run packer build .\test-box.pkr.hcl (see the content of the .pkr.hcl file below)
Plugin and Packer version
packer: 1.8.5
vagrant plugin: 1.0.3
Simplified Packer Buildfile
packer {
required_plugins {
vagrant = {
version = ">= 1.0.3"
source = "github.com/hashicorp/vagrant"
}
}
}
source "vagrant" "test-box" {
communicator = "ssh"
source_path = "minimal/trusty64"
provider = "virtualbox"
synced_folder = "."
}
build {
sources = ["source.vagrant.test-box"]
provisioner "file" {
source = "test-file"
destination = "C:/test-file"
}
}
Operating system and Environment details
Windows 10 host, 64 bits.
Log Fragments and crash.log files
2023/03/24 11:03:03 [INFO] Packer version: 1.8.5 [go1.18.9 windows amd64]
2023/03/24 11:03:03 [TRACE] discovering plugins in C:\ProgramData\chocolatey\lib\packer\tools
2023/03/24 11:03:03 [TRACE] discovering plugins in C:\Users\Foo\AppData\Roaming\packer.d\plugins
2023/03/24 11:03:03 [DEBUG] Discovered plugin: vagrant = C:\Users\Foo\AppData\Roaming\packer.d\plugins\github.com\hashicorp\vagrant\packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe
2023/03/24 11:03:03 [INFO] found external [-packer-default-plugin-name-] builders from vagrant plugin
2023/03/24 11:03:03 [INFO] found external [-packer-default-plugin-name- cloud] post-processors from vagrant plugin
2023/03/24 11:03:03 [TRACE] discovering plugins in .
2023/03/24 11:03:03 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/03/24 11:03:03 [INFO] PACKER_CONFIG env var set; attempting to open config file: C:\Users\Foo\AppData\Roaming\packer.config
2023/03/24 11:03:03 [WARN] Config file doesn't exist: C:\Users\Foo\AppData\Roaming\packer.config
2023/03/24 11:03:03 [INFO] Setting cache directory: C:\Users\Foo\Documents\test-box\packer_cache
e: cannot determine if process is in background: Process background check error: not implemented yet
2023/03/24 11:03:03 [TRACE] listing potential installations for "github.com/hashicorp/vagrant" that match ">= 1.0.3". plugingetter.ListInstallationsOptions{FromFolders:[]string{"C:\\ProgramData\\chocolatey\\lib\\packer\\tools\\packer.exe", ".", "C:\\Users\\Foo\\AppData\\Roaming\\packer.d\\plugins"}, BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"windows", ARCH:"amd64", Ext:".exe", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0xc0001a1000)}}}}
2023/03/24 11:03:03 [TRACE] Found the following "github.com/hashicorp/vagrant" installations: [{C:\Users\Foo\AppData\Roaming\packer.d\plugins\github.com\hashicorp\vagrant\packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe v1.0.3}]
2023/03/24 11:03:03 [INFO] found external [-packer-default-plugin-name-] builders from vagrant plugin
2023/03/24 11:03:03 [INFO] found external [-packer-default-plugin-name- cloud] post-processors from vagrant plugin
2023/03/24 11:03:03 [TRACE] Starting external plugin C:\Users\Foo\AppData\Roaming\packer.d\plugins\github.com\hashicorp\vagrant\packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe start builder -packer-default-plugin-name-
2023/03/24 11:03:03 Starting plugin: C:\Users\Foo\AppData\Roaming\packer.d\plugins\github.com\hashicorp\vagrant\packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe []string{"C:\\Users\\Foo\\AppData\\Roaming\\packer.d\\plugins\\github.com\\hashicorp\\vagrant\\packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe", "start", "builder", "-packer-default-plugin-name-"}
2023/03/24 11:03:03 Waiting for RPC address for: C:\Users\Foo\AppData\Roaming\packer.d\plugins\github.com\hashicorp\vagrant\packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe
2023/03/24 11:03:03 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:03 Plugin port range: [10000,25000]
2023/03/24 11:03:03 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:03 Plugin address: tcp 127.0.0.1:10000
2023/03/24 11:03:03 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:03 Waiting for connection...
2023/03/24 11:03:03 Received tcp RPC address for C:\Users\Foo\AppData\Roaming\packer.d\plugins\github.com\hashicorp\vagrant\packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe: addr is 127.0.0.1:10000
2023/03/24 11:03:03 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:03 Serving a plugin connection...
2023/03/24 11:03:03 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:03 [TRACE] starting builder -packer-default-plugin-name-
2023/03/24 11:03:03 [TRACE] Starting internal plugin packer-provisioner-file
2023/03/24 11:03:03 Starting plugin: C:\ProgramData\chocolatey\lib\packer\tools\packer.exe []string{"C:\\ProgramData\\chocolatey\\lib\\packer\\tools\\packer.exe", "plugin", "packer-provisioner-file"}
2023/03/24 11:03:03 Waiting for RPC address for: C:\ProgramData\chocolatey\lib\packer\tools\packer.exe
2023/03/24 11:03:03 packer.exe plugin: [INFO] Packer version: 1.8.5 [go1.18.9 windows amd64]
2023/03/24 11:03:03 packer.exe plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/03/24 11:03:03 packer.exe plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: C:\Users\Foo\AppData\Roaming\packer.config
2023/03/24 11:03:03 packer.exe plugin: [WARN] Config file doesn't exist: C:\Users\Foo\AppData\Roaming\packer.config
2023/03/24 11:03:03 packer.exe plugin: [INFO] Setting cache directory: C:\Users\Foo\Documents\test-box\packer_cache
2023/03/24 11:03:03 packer.exe plugin: args: []string{"packer-provisioner-file"}
2023/03/24 11:03:03 packer.exe plugin: Plugin port range: [10000,25000]
2023/03/24 11:03:03 packer.exe plugin: Plugin address: tcp 127.0.0.1:10000
2023/03/24 11:03:03 Received tcp RPC address for C:\ProgramData\chocolatey\lib\packer\tools\packer.exe: addr is 127.0.0.1:10000
2023/03/24 11:03:03 packer.exe plugin: Waiting for connection...
2023/03/24 11:03:03 packer.exe plugin: Serving a plugin connection...
2023/03/24 11:03:03 ui: vagrant.test-box: output will be in this color.
2023/03/24 11:03:03 ui:
2023/03/24 11:03:03 Build debug mode: false
2023/03/24 11:03:03 Force build: false
2023/03/24 11:03:03 On error:
2023/03/24 11:03:03 Waiting on builds to complete...
2023/03/24 11:03:03 Starting build run: vagrant.test-box
2023/03/24 11:03:03 Running builder:
2023/03/24 11:03:03 [INFO] (telemetry) Starting builder vagrant.test-box
2023/03/24 11:03:03 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:03 Calling Vagrant CLI: []string{"--version"}
2023/03/24 11:03:03 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:03 [vagrant driver] stdout: Vagrant 2.3.4
2023/03/24 11:03:04 ui: ==> vagrant.test-box: Creating a Vagrantfile in the build directory...
2023/03/24 11:03:04 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:04 Created vagrantfile at C:\Users\Foo\Documents\test-box\output-test-box\Vagrantfile
2023/03/24 11:03:04 ui: ==> vagrant.test-box: Adding box using vagrant box add ...
2023/03/24 11:03:04 ui: vagrant.test-box: (this can take some time if we need to download the box)
2023/03/24 11:03:04 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:04 [vagrant] Calling box add with following args minimal/trusty64 --provider virtualbox
2023/03/24 11:03:04 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:04 Calling Vagrant CLI: []string{"box", "add", "minimal/trusty64", "--provider", "virtualbox"}
2023/03/24 11:03:08 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:08 [vagrant driver] stdout: ==> box: Loading metadata for box 'minimal/trusty64'
2023/03/24 11:03:08 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:08 [vagrant driver] stdout: box: URL: https://vagrantcloud.com/minimal/trusty64
2023/03/24 11:03:09 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:09 [vagrant driver] stdout: ==> box: Adding box 'minimal/trusty64' (v14.04.3) for provider: virtualbox
2023/03/24 11:03:09 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:09 [vagrant driver] stderr: The box you're attempting to add already exists. Remove it before
2023/03/24 11:03:09 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:09 [vagrant driver] stderr: adding it again or add it with the `--force` flag.
2023/03/24 11:03:09 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:09 [vagrant driver] stderr:
2023/03/24 11:03:09 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:09 [vagrant driver] stderr: Name: minimal/trusty64
2023/03/24 11:03:09 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:09 [vagrant driver] stderr: Provider: virtualbox
2023/03/24 11:03:09 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:09 [vagrant driver] stderr: Version: 14.04.3
2023/03/24 11:03:09 ui: ==> vagrant.test-box: Calling Vagrant Up (this can take some time)...
2023/03/24 11:03:09 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:09 Calling Vagrant CLI: []string{"up", "source", "--provider=virtualbox"}
2023/03/24 11:03:13 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:13 [vagrant driver] stdout: Bringing machine 'source' up with 'virtualbox' provider...
2023/03/24 11:03:15 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:15 [vagrant driver] stderr: There are errors in the configuration of this machine. Please fix
2023/03/24 11:03:15 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:15 [vagrant driver] stderr: the following errors and try again:
2023/03/24 11:03:15 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:15 [vagrant driver] stderr:
2023/03/24 11:03:15 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:15 [vagrant driver] stderr: vm:
2023/03/24 11:03:15 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:15 [vagrant driver] stderr: * The host path of the shared folder is missing: C:UsersFooDocuments est-box
2023/03/24 11:03:15 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:15 [vagrant driver] stderr:
2023/03/24 11:03:15 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:15 Calling Vagrant CLI: []string{"ssh-config", "source"}
2023/03/24 11:03:20 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:20 [vagrant driver] stderr: The provider for this Vagrant-managed machine is reporting that it
2023/03/24 11:03:20 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:20 [vagrant driver] stderr: is not yet ready for SSH. Depending on your provider this can carry
2023/03/24 11:03:20 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:20 [vagrant driver] stderr: different meanings. Make sure your machine is created and running and
2023/03/24 11:03:20 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:20 [vagrant driver] stderr: try again. Additionally, check the output of `vagrant status` to verify
2023/03/24 11:03:20 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:20 [vagrant driver] stderr: that the machine is in the state that you expect. If you continue to
2023/03/24 11:03:20 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:20 [vagrant driver] stderr: get this error message, please view the documentation for the provider
2023/03/24 11:03:20 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:20 [vagrant driver] stderr: you're using.
2023/03/24 11:03:20 ui: ==> vagrant.test-box: destroying Vagrant box...
2023/03/24 11:03:20 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:20 Calling Vagrant CLI: []string{"destroy", "-f", "source"}
2023/03/24 11:03:27 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:27 [vagrant driver] stdout: ==> source: VM not created. Moving on...
2023/03/24 11:03:27 ui: ==> vagrant.test-box: Deleting output directory...
2023/03/24 11:03:27 packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe plugin: 2023/03/24 11:03:27 Error removing output dir: remove output-test-box\Vagrantfile: Le processus ne peut pas accéder au fichier car ce fichier est utilisé par un autre processus.
2023/03/24 11:03:29 [INFO] (telemetry) ending vagrant.test-box
2023/03/24 11:03:29 ui error: Build 'vagrant.test-box' errored after 25 seconds 519 milliseconds: error: SSH Port was not properly retrieved from SSHConfig.
2023/03/24 11:03:29 ui:
==> Wait completed after 25 seconds 519 milliseconds
2023/03/24 11:03:29 machine readable: error-count []string{"1"}
2023/03/24 11:03:29 ui error:
==> Some builds didn't complete successfully and had errors:
2023/03/24 11:03:29 machine readable: vagrant.test-box,error []string{"error: SSH Port was not properly retrieved from SSHConfig."}
2023/03/24 11:03:29 ui error: --> vagrant.test-box: error: SSH Port was not properly retrieved from SSHConfig.
2023/03/24 11:03:29 ui:
==> Builds finished but no artifacts were created.
2023/03/24 11:03:29 [INFO] (telemetry) Finalizing.
2023/03/24 11:03:29 waiting for all plugin processes to complete...
2023/03/24 11:03:29 [ERR] yamux: Failed to read header: read tcp 127.0.0.1:64824->127.0.0.1:10000: wsarecv: Une connexion existante a dû être fermée par l’hôte distant.
2023/03/24 11:03:29 [ERR] yamux: Failed to read header: read tcp 127.0.0.1:64823->127.0.0.1:10000: wsarecv: Une connexion existante a dû être fermée par l’hôte distant.
2023/03/24 11:03:29 C:\ProgramData\chocolatey\lib\packer\tools\packer.exe: plugin process exited
2023/03/24 11:03:29 C:\Users\Foo\AppData\Roaming\packer.d\plugins\github.com\hashicorp\vagrant\packer-plugin-vagrant_v1.0.3_x5.0_windows_amd64.exe: plugin process exited
Overview of the Issue
When run on a Windows host, the absolute path generated in
Vagrantfilefromsynced_folderconfiguration property contains only single backslash characters (\) as path separators. This is not supported becauseVagrantfileis a Ruby file and backslash is an escape character in RubyReproduction Steps
On a Windows host, with packer, vagrant and virtualbox installed, run
packer build .\test-box.pkr.hcl(see the content of the.pkr.hclfile below)Plugin and Packer version
packer: 1.8.5
vagrant plugin: 1.0.3
Simplified Packer Buildfile
Operating system and Environment details
Windows 10 host, 64 bits.
Log Fragments and crash.log files