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

Drive letter case is different from the process.cwd #18468

Open
7 tasks done
sheremet-va opened this issue Oct 25, 2024 · 0 comments
Open
7 tasks done

Drive letter case is different from the process.cwd #18468

sheremet-va opened this issue Oct 25, 2024 · 0 comments
Labels
p2-edge-case Bug, but has workaround or limited in scope (priority) windows only

Comments

@sheremet-va
Copy link
Member

sheremet-va commented Oct 25, 2024

Describe the bug

This is a very niche issue that affects Vitest and anyone using the ModuleRunner alongside native imports.

This issue appears only when running Vite in CMD.EXE and only if process.cwd() has a lowercase drive letter (c:/ instead of C:/).

The incorrect values are present in every path returned from the this.resolve also uses a different drive letter casing (note: rollup returns the same case as in process.cwd())

Reproduction

https://stackblitz.com/edit/node-86cw3m?file=vite.config.js,index.js,basic.js,test.js,package-lock.json

Steps to reproduce

# make sure the drive letter is lowercase
cd c:\Users\me\test
npm install
npm run dev

All imports are transformed with /@fs/ prefix instead of being relative to the localhost. (and they also use the wrong casing)

import * as test from '/@fs/C:/Users/me/test/basic.js'

The value returned from the server.pluginContainer.resolveId also changes the casing.

The casing is kept as is only if resolve.preserveSymlink is enabled. This is because the normalization happens during the realpathSync call:

function getRealPath(resolved: string, preserveSymlinks?: boolean): string {

function windowsSafeRealPathSync(path: string): string {

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (24) x64 12th Gen Intel(R) Core(TM) i9-12900KF
    Memory: 51.11 GB / 63.85 GB
  Binaries:
    Node: 20.14.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 3.5.0 - C:\Program Files\nodejs\yarn.CMD
    npm: 10.7.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.12.2 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527

Used Package Manager

npm

Logs

No response

Validations

@sheremet-va sheremet-va added windows only p2-edge-case Bug, but has workaround or limited in scope (priority) labels Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-edge-case Bug, but has workaround or limited in scope (priority) windows only
Projects
None yet
Development

No branches or pull requests

1 participant