File Provisioner Fails on Windows SSH with Spaces In Path
- Dominant language
- Go
- Stars
- 15.8k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
#### Community Note
* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue or have submitted a pull request, please leave a comment
When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.
#### Overview of the Issue
Trying to copy a directory to a destination with spaces in the path fails. Similar to #2714 but for SSH instead of WinRM.
#### Reproduction Steps
Try to copy a directory to a destination with spaces in the path.
### Packer version
Packer v1.8.3
### Simplified Packer Template
Tried both
```hcl
provisioner "file" {
source = "roslyn"
destination = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\WDExpress\\MSBuild\\15.0\\Bin\\Roslyn"
}
```
and
```hcl
provisioner "file" {
source = "roslyn"
destination = "\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\WDExpress\\MSBuild\\15.0\\Bin\\Roslyn\""
}
```
### Operating system and Environment details
Windows x64
### Log Fragments and crash.log files
```
==> FMPLTestStation.amazon-ebs.FMPLTestStation: Uploading roslyn => C:\Program Files (x86)\Microsoft Visual Studio\2017\WDExpress\MSBuild\15.0\Bin\Roslyn
==> FMPLTestStation.amazon-ebs.FMPLTestStation: Upload failed: Process exited with status 1
2023/03/23 16:22:23 ui: ==> FMPLTestStation.amazon-ebs.FMPLTestStation: Uploading roslyn => "C:\Program Files (x86)\Microsoft Visual Studio\2017\WDExpress\MSBuild\15.0\Bin\Roslyn"
2023/03/23 16:22:23 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: 2023/03/23 16:22:23 [DEBUG] Upload dir 'roslyn' to '"C:\Program Files (x86)\Microsoft Visual Studio\2017\WDExpress\MSBuild\15.0\Bin\Roslyn"'
2023/03/23 16:22:23 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: 2023/03/23 16:22:23 [DEBUG] Opening new ssh session
2023/03/23 16:22:23 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: 2023/03/23 16:22:23 [DEBUG] Starting remote scp process: scp -rvt "C:\Program Files (x86)\Microsoft Visual Studio\2017\WDExpress\MSBuild\15.0\Bin\Roslyn"
2023/03/23 16:22:23 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: 2023/03/23 16:22:23 [DEBUG] Started SCP session, beginning transfers...
2023/03/23 16:22:23 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: 2023/03/23 16:22:23 [DEBUG] No trailing slash, creating the source directory name
2023/03/23 16:22:23 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: 2023/03/23 16:22:23 [DEBUG] SCP: starting directory upload: roslyn
2023/03/23 16:22:24 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: 2023/03/23 16:22:24 [DEBUG] SCP session complete, closing stdin pipe.
2023/03/23 16:22:24 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: 2023/03/23 16:22:24 [DEBUG] Waiting for SSH session to complete.
2023/03/23 16:22:24 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: 2023/03/23 16:22:24 [DEBUG] scp stderr (length 499): x86 : The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
2023/03/23 16:22:24 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: spelling of the name, or if a path was included, verify that the path is correct and try again.
2023/03/23 16:22:24 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: At line:1 char:32
2023/03/23 16:22:24 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: + scp.exe -rvt C:\Program Files (x86)\Microsoft Visual Studio\2017\WDEx ...
2023/03/23 16:22:24 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: + ~~~
2023/03/23 16:22:24 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: + CategoryInfo : ObjectNotFound: (x86:String) [], CommandNotFoundException
2023/03/23 16:22:24 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: + FullyQualifiedErrorId : CommandNotFoundException
2023/03/23 16:22:24 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin:
2023/03/23 16:22:24 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: 2023/03/23 16:22:24 [DEBUG] non-zero exit status: 1, Process exited with status 1
2023/03/23 16:22:24 packer-plugin-amazon_v1.1.3_x5.0_windows_amd64.exe plugin: 2023/03/23 16:22:24 [DEBUG] scp output:
2023/03/23 16:22:24 ui error: ==> FMPLTestStation.amazon-ebs.FMPLTestStation: Upload failed: Process exited with status 1
```
Contributor guide
Research direction
Start with the file provisioner’s SSH upload path and the remote scp command shown in the log, using the supplied HCL template on Windows. Reproduce the failure with a destination containing spaces and compare the generated command with the PowerShell error. Done means copying the directory succeeds for that destination.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100