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

vite cannot support yarn2 Global Cache #8908

Closed
7 tasks done
frg2089 opened this issue Jul 4, 2022 · 7 comments
Closed
7 tasks done

vite cannot support yarn2 Global Cache #8908

frg2089 opened this issue Jul 4, 2022 · 7 comments
Labels
duplicate This issue or pull request already exists

Comments

@frg2089
Copy link

frg2089 commented Jul 4, 2022

Describe the bug

when i use yarn berry and set enableGlobalCache: true.
i got an error look's like this:

X [ERROR] Could not resolve "./C:/Users/<User Name>/AppData/Local/Yarn/Berry/cache/<Package>.zip/node_modules/<Path to>.js"

it's maybe an esbuild bug.

Reproduction

https://github.com/frg2089/vite-bug

System Info

Need to install the following packages:
  envinfo
Ok to proceed? (y) y

  System:
    OS: Windows 10 10.0.25140
    CPU: (8) x64 AMD Ryzen 5 3500U with Radeon Vega Mobile Gfx
    Memory: 5.53 GB / 17.94 GB
  Binaries:
    Node: 18.2.0 - D:\Program Files\nodejs\node.EXE
    Yarn: 4.0.0-rc.6 - D:\Program Files\nodejs\yarn.CMD
    npm: 8.11.0 - D:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.25140.1000.0), Chromium (103.0.1264.44)
    Internet Explorer: 11.0.25140.1000

Used Package Manager

yarn

Logs

Click to expand!
placeholder sample
<Path To Local Appdata> %LOCALAPPDATA%
<Path To Project> e.g. D:\Repos\vite-demo
  vite v2.9.13 dev server running at:

  > Local: http://localhost:3000/
  > Network: use `--host` to expose

  ready in 523ms.

✘ [ERROR] Could not resolve "./<Path To Local Appdata>/Yarn/Berry/cache/@microsoft-fast-components-npm-2.30.6-d634ccef7f-7.zip/node_modules/@microsoft/fast-components/dist/esm/index.js"

    dep:@microsoft_fast-components:2:14:
      2 │ export * from "./<Path To Local Appdata>/Yarn/Berry/cache/@microsoft-fast-components-npm-2.30.6-d...
        ╵               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

09:25:02 [vite] error while updating dependencies:
Error: Build failed with 1 error:
dep:@microsoft_fast-components:2:14: ERROR: Could not resolve "./<Path To Local Appdata>/Yarn/Berry/cache/@microsoft-fast-components-npm-2.30.6-d634ccef7f-7.zip/node_modules/@microsoft/fast-components/dist/esm/index.js"
    at failureErrorWithLog (<Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1605:15)
    at <Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1251:28
    at runOnEndCallbacks (<Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1034:63)
    at buildResponseToResult (<Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1249:7)
    at <Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:1358:14
    at <Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:666:9
    at handleIncomingPacket (<Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:763:9)
    at Socket.readFromStdout (<Path To Project>\vite-bug\.yarn\unplugged\esbuild-npm-0.14.48-d0430cb883\node_modules\esbuild\lib\main.js:632:7)
    at Socket.emit (node:events:527:28)
    at addChunk (node:internal/streams/readable:324:12)

Validations

@sapphi-red
Copy link
Member

sapphi-red commented Jul 4, 2022

I suppose the problem here is your project locates in C drive but the yarn global cache locates in D drive and Vite fails to handle that.
related: #4302 #4635

@frg2089
Copy link
Author

frg2089 commented Jul 4, 2022

I suppose the problem here is your project locates in C drive but the yarn global cache locates in D drive and Vite fails to handle that.

my global cache locates in C drive and my project locates in D drive.

@sapphi-red
Copy link
Member

My bad. Anyway, the cross-drive symlink/junction is the root cause here.
Maybe it will work if you move the global cache to C drive.

@frg2089
Copy link
Author

frg2089 commented Jul 4, 2022

Maybe it will work if you move the global cache to C drive.

I disabled the global cache and it worked.
they will storaged packages into <project path>\.yarn\cache.

@HasanMothaffar
Copy link

HasanMothaffar commented Jul 21, 2022

I can reproduce the issue on a Windows 11 machine. We have enableGlobalCache: true in our yarnrc.yml file, and I'm getting this error

image

The error's not exclusive to this package. I'm getting similar errors for other packages like react and @emotion/cache.
I was able to resolve the issue by disabling the global cache, as @frg2089 suggested.

I'd be glad to provide more info if useful.

@sapphi-red
Copy link
Member

@HasanMothaffar Would you test if moving global cache to the same drive works?
yarn config set cache-folder <path> is the command, I suppose.
https://classic.yarnpkg.com/en/docs/cli/cache#toc-change-the-cache-path-for-yarn

YamanQD pushed a commit to YamanQD/Labeeb that referenced this issue Aug 13, 2022
I had to disable yarn's global cache to do this because nearly everything seems to be broken with Yarn.

vitejs/vite#8908
@sapphi-red
Copy link
Member

Closing as lack of response and I guess this is a duplicate of #4635

@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2022
@sapphi-red sapphi-red added duplicate This issue or pull request already exists and removed windows only pending triage labels Oct 17, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Nov 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants