Skip to content

Vite dev server holds a lock on directories that have nested directories #11938

@bmcbarron

Description

@bmcbarron

Describe the bug

While debugging a firebase issue in a sveltekit project, I discovered that many folks are having directory renaming permission errors. I tracked this down to a minimal use case of running just a Vite dev server.

While Vite dev server is running, renaming a directory in the project root fails, if and only if it contains a subdirectory.

Note that this does not occur on stackblitz (https://stackblitz.com/edit/vitejs-vite-cbseww?file=package.json), so it's probably OS-dependent. I'm using git bash on Windows 11. However, folks in the linked bug see this on Windows 10 as well.

Reproduction

https://github.com/bmcbarron/vite-bug-repro

Steps to reproduce

# On Windows 11, git bash version 5.1.16(1)-release (x86_64-pc-msys)
npm create vite@latest # Choose all defaults
cd vite-project
npm i
npm run dev # Leave running
# In new shell
cd vite-project
mkdir a
mkdir a/b
mv a c # Fails with permission denied
rmdir a/b # OR stop vite instead of removing nested directory
mv a c # Succeeds

System Info

System:
    OS: Windows 10 10.0.22621
    CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
    Memory: 2.41 GB / 15.94 GB
  Binaries:
    Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
    npm: 9.4.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 106.0.5249.103
    Edge: Spartan (44.22621.1105.0), Chromium (109.0.1518.70)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    vite: ^4.1.0 => 4.1.1

Used Package Manager

npm

Logs

Click to expand! ```shell brian@yellow MINGW64 /c/git/vite.test/vite-project $ mkdir a

brian@yellow MINGW64 /c/git/vite.test/vite-project
$ mkdir a/b

brian@yellow MINGW64 /c/git/vite.test/vite-project
$ mv a foo
mv: cannot move 'a' to 'foo': Permission denied

brian@yellow MINGW64 /c/git/vite.test/vite-project
$ rmdir a/b

brian@yellow MINGW64 /c/git/vite.test/vite-project
$ mv a foo

brian@yellow MINGW64 /c/git/vite.test/vite-project

</details>

### Validations

- [X] Follow our [Code of Conduct](https://github.com/vitejs/vite/blob/main/CODE_OF_CONDUCT.md)
- [X] Read the [Contributing Guidelines](https://github.com/vitejs/vite/blob/main/CONTRIBUTING.md).
- [X] Read the [docs](https://vitejs.dev/guide).
- [X] Check that there isn't [already an issue](https://github.com/vitejs/vite/issues) that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to [vuejs/core](https://github.com/vuejs/core) instead.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitejs/vite/discussions) or join our [Discord Chat Server](https://chat.vitejs.dev/).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug: upstreamBug in a dependency of Vite

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions