nushell icon indicating copy to clipboard operation
nushell copied to clipboard

mv deleted folders, no error

Open DeadRobotDev opened this issue 3 years ago • 5 comments

Describe the bug

Tried to rename a couple of project folders to snake case versions. It succeeded on one, and deleted the other two.

Similar to #5296, except on Windows 10 and no error.

How to reproduce

  1. mkdir Test
  2. mv Test test

Expected behavior

I expected nu to report an error and not do anything, or rename the folder.

Screenshots

No response

Configuration

key value
version 0.68.1
branch
commit_hash e76b3d61deef832adce76b0f73f19131de8cbc9e
build_os windows-x86_64
build_target x86_64-pc-windows-msvc
rust_version rustc 1.63.0 (4b91a6ea7 2022-08-08)
rust_channel stable-x86_64-pc-windows-msvc
cargo_version cargo 1.63.0 (fd9c4297c 2022-07-01)
pkg_version 0.68.1
build_time 2022-09-08 21:41:56 +00:00
build_rust_channel release
features database, dataframe, default, trash, which, zip
installed_plugins

Additional context

No response

DeadRobotDev avatar Sep 19 '22 00:09 DeadRobotDev

Yikes - we're very sorry about the data loss! Thank you for the bug report.

I can reproduce this on Windows but not Linux. Guessing it's related to the filesystem being case-insensitive on Windows. I'll take a closer look.

rgwood avatar Sep 19 '22 02:09 rgwood

This is looking like a bug in a library we use - specifically the fs_extra::dir::move_dir() function. I'll put together a minimal repro and file an issue over there.

If fs_extra can't fix this before the next Nushell release (Sept 27), we might want to fork it.

rgwood avatar Sep 19 '22 02:09 rgwood

I imagine this is an issue on all file systems with case-insensitivity.

And I know this seems to be a dependency issue, but I would still suggest to add additional test cases for similar scenarios, because deleting data like this absolutely shouldn't happen.

Zapeth avatar Sep 21 '22 22:09 Zapeth

deleting data like this absolutely shouldn't happen.

Agreed. We'd very much welcome PRs in this area.

rgwood avatar Sep 21 '22 23:09 rgwood

I've written up a few tests and will add them when the fs_extra fix is ready.

rgwood avatar Sep 22 '22 03:09 rgwood

Just merged a fix for this, it will be included in the next version of Nushell.

To make a long story short, we no longer use the buggy dependency when doing a normal mv foo Foo. When the dependency is fixed, I'll upgrade our version of it as an extra safeguard.

rgwood avatar Sep 23 '22 18:09 rgwood

Is this able to be closed now?

webbedspace avatar Nov 09 '22 14:11 webbedspace

Probably not. We mostly worked around it on our side, but we can still call fs_extra in a fallback path. We might need to replace our use of fs_extra or submit a patch upstream.

rgwood avatar Nov 09 '22 16:11 rgwood

I realise this happened to me before, never though this was the culprit 💀

melMass avatar Oct 31 '23 14:10 melMass