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

CachedFsUtils cause issue on Windows #17797

Open
7 tasks done
Maxim-Mazurok opened this issue Jul 31, 2024 · 1 comment
Open
7 tasks done

CachedFsUtils cause issue on Windows #17797

Maxim-Mazurok opened this issue Jul 31, 2024 · 1 comment
Labels
pending triage regression The issue only appears after a new release

Comments

@Maxim-Mazurok
Copy link

Maxim-Mazurok commented Jul 31, 2024

Describe the bug

TLDR, outDir was bla-bla/Bin, but vite built it into bla-bla/bin because it already existed, and then tried to to serve bla-bla/Bin for preview which failed.

I've had the following vite.config.ts:

const frontEndProjectRootDirectory = __dirname;

export default defineConfig({
  build: {
    outDir: join(frontEndProjectRootDirectory, "Bin", "Frontend", "public"),
    emptyOutDir: true,
  },
});

As you can see, it has Bin folder in the path, with capital B.

Now if I already have a bin folder (lowercase b) - vite will build into it instead of creating Bin folder, and later fail to use that folder during vite preview due to CachedFsUtils.

With the following change in https://github.com/vitejs/vite/blob/main/packages/vite/src/node/fsUtils.ts#L63, all works fine:

-fsUtils = createCachedFsUtils(config)
+fsUtils = commonFsUtils

Reproduction

https://github.com/Maxim-Mazurok/vite-cache-fs-repro

Steps to reproduce

  1. Use Windows
  2. Make sure case sensitivity is disabled for the path you'll be testing https://learn.microsoft.com/en-us/windows/wsl/case-sensitivity#modify-case-sensitivity
  3. Clone https://github.com/Maxim-Mazurok/vite-cache-fs-repro
  4. npm ci
  5. npm run build - should build into existing bin folder (included in repo) instead of Bin
  6. npm run preview
  7. Visit preview URL, it should return 404 (because it tries to server "Bin" but there's only "bin")

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i9-12900H
    Memory: 30.63 GB / 63.68 GB
  Binaries:
    Node: 18.14.1 - ~\AppData\Local\nvs\default\node.EXE
    npm: 9.3.1 - ~\AppData\Local\nvs\default\npm.CMD
  Browsers:
    Edge: Chromium (126.0.2592.102)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    vite: ^5.3.4 => 5.3.5

Used Package Manager

npm

Logs

No response

Validations

@Maxim-Mazurok
Copy link
Author

Related to #15279

A workaround is to disable server.fs.cachedChecks in vite config:

import { defineConfig } from "vite";
import path from "path";

export default defineConfig({
  build: {
    outDir: path.join(__dirname, "Bin"),
    emptyOutDir: true,
  },
  server: {
    fs: {
      cachedChecks: false
    }
  }
});

@bluwy bluwy added the regression The issue only appears after a new release label Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending triage regression The issue only appears after a new release
Projects
None yet
Development

No branches or pull requests

2 participants