Skip to content

Archives with long paths fail to extract #44

Open
@aaronpowell

Description

@aaronpowell

If you try and expand an archive which contains files that have long paths in it Expand-Archive will raise errors and not properly expand the contents.

Repo script

New-Item -Path "C:\tmp" -ItemType Directory
Invoke-WebRequest -Uri 'https://github.com/nodejs/node-chakracore/releases/download/node-chakracore-v8.6.0/node-v8.6.0-win-x64.zip' -OutFile 'C:\tmp\node-v8.6.0-win-x64.zip'
Push-Location 'C:\tmp'
Expand-Archive -Path 'node-v8.6.0-win-x64.zip'
Pop-Location

Error message is:

New-Item : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
At C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:984 char:25
+ ...             New-Item $currentArchiveEntryFileInfo.DirectoryName -Type ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (C:\tmp\node-v8....les\is-arrayish:String) [New-Item], PathTooLongException
    + FullyQualifiedErrorId : CreateDirectoryIOError,Microsoft.PowerShell.Commands.NewItemCommand

It would appear to be this line that causes the problem, so it's related to how New-Item handles long paths.

psd1

@{
GUID="eb74e8da-9ae2-482a-a648-e96550fb8733"
Author="Microsoft Corporation"
CompanyName="Microsoft Corporation"
Copyright="� Microsoft Corporation. All rights reserved."
ModuleVersion="1.0.1.0"
FunctionsToExport = @('Compress-Archive', 'Expand-Archive')
DotNetFrameworkVersion = 4.5
CmdletsToExport = @()
AliasesToExport = @()
NestedModules="Microsoft.PowerShell.Archive.psm1"
HelpInfoURI = 'https://go.microsoft.com/fwlink/?LinkId=393254'
}

Environment

OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.16299 N/A Build 16299
System Model:              Surface Pro 4
System Type:               x64-based PC

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions