Skip to content

Remove-Item regression from 7.1.3 - fails to recursively delete dir when path ends with a slash #15492

@rkeithhill

Description

@rkeithhill

Steps to reproduce

(mkdir foo && new-item foo\bar.txt) > $null
Remove-Item -Recurse .\foo\

Expected behavior

I expect this to work as it does wok in v7.1.3

C:\Users\Keith\Code\dotnet
05-29 14:48:34 7> Remove-Item -Recurse .\foo\
C:\Users\Keith\Code\dotnet

Actual behavior

It fails on v7.2.0-preview.5 but only if the path ends with a slash. The bummer is that PowerShell's tab-completion on the path is what adds the trailing slash.

C:\Users\Keith\Code\dotnet
05-29 14:50:45 94> Remove-Item -Recurse .\foo\
Remove-Item: Cannot remove item C:\Users\Keith\Code\dotnet\foo\: The directory is not empty. : 'C:\Users\Keith\Code\dotnet\foo\'
C:\Users\Keith\Code\dotnet

If you remove the trailing slash, v7.2.0-preview.5 works:

C:\Users\Keith\Code\dotnet
05-29 14:53:25 97> Remove-Item -Recurse .\foo
C:\Users\Keith\Code\dotnet

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.0-preview.5
PSEdition                      Core
GitCommitId                    7.2.0-preview.5
OS                             Microsoft Windows 10.0.19043
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution-DuplicateThe issue is a duplicate.WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions