Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd cannot remove the directory that WSL made #5632

Closed
haojiwei opened this issue Jul 22, 2020 · 4 comments
Closed

cmd cannot remove the directory that WSL made #5632

haojiwei opened this issue Jul 22, 2020 · 4 comments
Labels

Comments

@haojiwei
Copy link

Environment

Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.19041.0 Microsoft Windows NT 10.0.19041.0

Ubuntu Release:        18.04

Linux version 4.19.104-microsoft-standard (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP Wed Feb 19 06:37:35 UTC 2020

Steps to reproduce

In mounted file path of windows (such as /mnt/c/Users/test/Documents/testDir) , run mkdir ... in WSL, and the a new directory named ... was created.

Using right click + delete can delete ... or testDir failed to delete both the directories.

Using rd /s ... in cmd, terminal showed The process cannot access the file because it is being used by another process.

Then I killed wslhost.exe process, run rd /s ... in cmd again, terminal showed Cannot Remove folder because the directory is not empty.

Expected behavior

Delete directory ... in windows or cannot create the directory of illegal name in mounted window drives by WSL.

Actual behavior

Cannot delete the directory ... and the directory which contains ... in windows.

@therealkenc
Copy link
Collaborator

therealkenc commented Jul 22, 2020

Cannot Remove folder because the directory is not empty.

This is by-design Windows. Those ... dots in your repro are being interpreted by cmd.exe as ..\. (pretty sure). If you want to delete that directory from the windows side, you want rd \\?\C:\Users\there\tmp\.... Which isn't in any way recomended, but that's how you'd remove it if one insisted. Goes without saying the sane way to delete the quirky directory you created on the WSL side would be from the WSL side. You'll need to make sure there aren't any open handles to the directory (note the cd / below) but that's Windows behavior also, or #1529 (message) depending on one's disposition.

image

@haojiwei
Copy link
Author

@therealkenc
For the The process cannot access the file because it is being used by another process, I exit from wsl in the directory where creating the directory which is the parent directory of .... According to the #1529, the file descriptors are cached. But I reboot my computer, the delete operation still results in The process cannot access the file because it is being used by another process.
It is by-design that stores the all state of WSL when the WINS computer shutdowns?

@therealkenc
Copy link
Collaborator

Disregard #1529, I only brought it up out of an abundance of caution. Forget I mentioned it. You are not getting The process cannot access the file because it is being used by another process because of #1529. The problem is your rd file syntax in Windows.

@haojiwei
Copy link
Author

@therealkenc
Thanks! Using \\?\prefix to prevent windows converting the path name to an NT-style name works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants