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

os: Remove empty directory fails with "process cannot access the file because it is being used by another process" on <= Windows 10 #58860

Closed
bep opened this issue Mar 4, 2023 · 1 comment

Comments

@bep
Copy link
Contributor

bep commented Mar 4, 2023

I don't have a simple test case for you, but some data points:

  • This is a new issue in Go 1.20. It's working OK in Go 1.19.
  • It's been reported failing on Windows 8 and 10. It always fail for me on my Windows 8 VM.
  • It's not failing on Windows 11.

The failing code is more or less the snippet below:

_, err = f.Readdirnames(1)
if err == io.EOF {
   // Empty dir.
   err = os.Remove(dirname)
  // Gets "process cannot access the file because it is being used by another process" on Windows <= 10.
}

And dirname has recently been used (but not anymore).

gohugoio/hugo#10781

@bep
Copy link
Contributor Author

bep commented Mar 4, 2023

OK, turns out I had the directory in question open, which now fails on Windows. I guess that's sensible. Closing.

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

No branches or pull requests

2 participants