Skip to content

Unclear error message when unzipping paths > 260 characters #78

@tyler-ball

Description

@tyler-ball

Description

By default Windows does not support paths > 260 characters. When trying to converge a cookbook that contains an embedded DSC resource, using policyfiles for dependency management, and testing using Test Kitchen an error occurs:

E, [2019-08-02T13:50:01.481897 #48646] ERROR -- tk-win16cor: Message: [WinRM::FS::Core::FileTransporter] Upload failed (exitcode: 0), but stderr present
Error HRESULT E_FAIL has been returned from a call to a COM component.
    + CategoryInfo          : OperationStopped: (:) [Invoke-Expression], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.PowerShell.Commands.InvokeExpressionCommand

This exception is being thrown by the extract_files.ps1 script. This COM call is hidden beneath layers of try/catch blocks and is hiding the actual error. After troubleshooting we found the underlying error:

Exception calling "ExtractToDirectory" with "2" argument(s) : "Could not find a part of the path 'C:\Users\Administrator\AppData\local\Temp\winrm-upload\tmpzip-856e18bfe2g171640fd43 a42gdcg5562gecb1e2\mitre_win_security-e0c717650c8f0ab2f3c6e0c3e4ca1a755d5479f8\files\default\cSecurityOptions\3.1.2\DSCResources\AccountAndBasicAuditing\AccountAndBasicAuditing.psm1'."

That path is longer than 260 characters and cannot be unzipped in standard Windows.

Environment

Test Kitchen target: Windows Server 2016 Core running in vcenter

Suggested fix

For current customers: https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file#enable-long-paths-in-windows-10-version-1607-and-later
Enhancement to winrm-fs: echo to stdout any caught exceptions in the try/catch logic of extract_files.ps1. Cannot echo to stderr because that would cause the run to fail via

elsif stderr != '\r\n' && stderr != ''

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions