Skip to content

Copy-Item is assuming case insensitive on Linux #1930

Closed

Description

Steps to reproduce

cd /tmp
mkdir a
mkdir A
touch a/b
cd A
Copy-Item ../a/b

Expected behavior

File copied.

Actual behavior

File not copied, and error:

Copy-Item : Cannot overwrite the item /tmp/A/b with itself.
At line:1 char:1
+ Copy-Item ../a/b
+ ~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (/tmp/A/b:String) [Copy-Item], IOException
    + FullyQualifiedErrorId : CopyError,Microsoft.PowerShell.Commands.CopyItemCommand

Environment data

Name                           Value
----                           -----
PSVersion                      6.0.0-alpha
PSEdition                      Core
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   3.0.0.0
GitCommitId                    v6.0.0-alpha.9
CLRVersion
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Activity

  1. added this to the milestone on Sep 29, 2016
  2. modified the milestones: , on Dec 19, 2016
  3. jeffbi commented on Feb 27, 2017

    @jeffbi

    The cmdlet does a case-insensitive comparison of the source and destination file paths, which is appropriate for Windows file systems. However, simply changing the test to case-sensitive on Linux is not sufficient since Linux is perfectly happy to use, for example, the FAT file system which is case-insensitive regardless of the OS using it.

    Removing the test entirely, and allowing the call to FileInfo.CopyTo to fail is probably reasonable, although the IOExceptions thrown on FullCLR, CoreCLR Windows, and CoreCLR Linux are different. On FullCLR, the exception's HRESULT is 0x80070050 (ERROR_FILE_EXISTS) and the Message property reflects that. In CoreCLR the HRESULT is 0x80070020 (ERROR_SHARING_VIOLATION) on Windows and 11 (EAGAIN) on Linux---in both cases the Message is "The process cannot access the file because it is being used by another process."

    Also, if we were to remove the test entirely on Linux and MacOS, users would not see the same error text across platforms.

  4. changed the title [-]Copy-Item is assuming case insensive on Linux[/-] [+]Copy-Item is assuming case insensitive on Linux[/+] on Mar 2, 2017
  5. added
    Committee-ReviewedPS-Committee has reviewed this and made a decision
    and removed
    Review - CommitteeThe PR/Issue needs a review from the PowerShell Committee
    on Mar 2, 2017
  6. SteveL-MSFT commented on Mar 2, 2017

    @SteveL-MSFT
    Member

    @PowerShell/powershell-committee we should honor the filesystem case-sensitivity instead of just assuming case-sensitive on Linux and case-insensitive on Windows

    edit: typo fixed, thanks Ilya (@iSazonov)

  7. modified the milestones: 6.0.0-beta1, on Mar 16, 2017
  8. iSazonov commented on Apr 22, 2017

    @iSazonov
    Collaborator

    Giovanni Bassi (@giggio) Thanks for your report! The Issue was fixed. You can recheck the fix in Alfa.19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Committee-ReviewedPS-Committee has reviewed this and made a decisionResolution-FixedThe issue is fixed.WG-Cmdletsgeneral cmdlet issues

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions