Skip to content

The mv command performs a copy even if the source and destination are on the same device. #12015

@hamflx

Description

@hamflx

Describe the bug

move C:\repos\my-project\node_modules to C:\.nd\a13 takes a long time if some files locked by a process:

C:\repos\my-project> mv node_modules\ \.nd\a13
Error:   × Could not move "C:\\repos\\my-project\\node_modules\\" to "C:\\.nd\\a13". Error Kind: The system cannot find the path specified. (os error 3)
   ╭─[entry #2:1:1]
 1  mv node_modules\ \.nd\a13
   ·    ──────┬──────
   ·          ╰── could not move
   ╰────

C:\repos\my-project> timeit {mv node_modules\ \.nd\a13}
Error:   × Could not move "C:\\repos\\my-project\\node_modules\\" to "C:\\.nd\\a13". Error Kind: The system cannot find the path specified. (os error 3)
   ╭─[entry #7:1:1]
 1  timeit {mv node_modules\ \.nd\a13}
   ·            ──────┬──────
   ·                  ╰── could not move
   ╰────


1min 58sec 687ms 682µs 600ns

How to reproduce

  1. Clone a large front-end project.
  2. Run pnpm install.
  3. cd node_modules to simulate a file being locked by a process.
  4. Open a new shell.
  5. Run mv node_modules \.nd. This command will take a long time and then fail.

Expected behavior

I expect the mv command failed immediately instead of after copy operation.

Screenshots

No response

Configuration

key value
version 0.90.2
branch main
commit_hash f24877b
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.74.1 (a28077b28 2023-12-04)
rust_channel 1.74.1-x86_64-pc-windows-msvc
cargo_version cargo 1.74.1 (ecb9851af 2023-10-18)
build_time 2024-02-29 11:23:06 +08:00
build_rust_channel debug
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins

and

key value
version 0.89.0
branch
commit_hash 2c1560e
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.73.0 (cc66ad468 2023-10-03)
rust_channel 1.73.0-x86_64-pc-windows-msvc
cargo_version cargo 1.73.0 (9c4383fb5 2023-08-26)
build_time 2024-01-09 20:28:44 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:needs-triageAn issue that hasn't had any proper look

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions