vitest-dev / vscode

VS Code extension for Vitest
https://vitest.dev/vscode
MIT License
744 stars 84 forks source link

Vitest not starting up due to failed version check on windows #88

Closed daple closed 1 year ago

daple commented 2 years ago

Describe the bug Hi there, Every time I start up vscode it keeps telling me, "Because Vitest version < 0.12.0 for every workspace folder, run/debug/watch tests from Vitest extension disabled."

Tried uninstall / install but it won't come up again.

Sth. I should be aware off ?

Thx!

To Reproduce have vitest 0.23.4 installed, used the cmd: npm init vue@3 to create a totally new package

installed your vitest extension.

Restart vscode, see error appearing.

Expected behavior possible to start the tests through test explorer or using the green play icon

Screenshots If applicable, add screenshots to help explain your problem. image

Environment windows 10, vscode : Version: 1.71.2 (user setup) Commit: 74b1f979648cc44d385a2286793c226e611f59e7 Datum: 2022-09-14T21:03:37.738Z Electron: 19.0.12 Chromium: 102.0.5005.167 Node.js: 16.14.2 V8: 10.2.154.15-electron.0 Betriebssystem: Windows_NT x64 10.0.19044 Sandkasten: No

Additional context same setup on macos works

gaokun commented 2 years ago

I got the same warning on MacOS

Vitest Plugin: 0.2.29
Vitest: 0.23.4
vscode: 1.17.2
MacOS: 11.4
Ewocker commented 1 year ago

same warning on MacOS

philwolstenholme commented 1 year ago

I have the same issue on a Mac, here's an example repo https://github.com/philwolstenholme/wolstenhol-11ty/

Extension version v0.2.29 Vitest version 0.24.0 Vite version: 3.1.0

dalilakatialeo commented 1 year ago

Same issue on Ubuntu 20.04.5.

Extension version v0.2.32 Vitest version 0.22.1 Vite version: 3.0.8 vscode: 1.72.0

JAKimball commented 1 year ago

I've seen this as well on Windows with Ubuntu 22.04 on WSL. I suspect the root cause could be a bug in vscode-server.

At least in my case when I've seen this, shutting down all VSCode instances and restarting has cleared up the problem, but it still re-occurs at random. I'll try to investigate a bit more if I see it again.

I suspect when this happens the extension does not even have a Vitest version number.

odranoelBR commented 1 year ago

Same issue on Ubuntu 22.04 Extension version v0.2.32 Vitest version 0.24.3 Vite version: 3.1.4 vscode: 1.73.0

toniengelhardt commented 1 year ago

Same, doesn't run tests on OS X Ventura.

darioielardi commented 1 year ago

Same here: macOS 13.0.1 Vitest 0.25.2 vitest-vscode 0.2.34

Lauro235 commented 1 year ago

Same here Windows 11 Vitest 0.26.3 vitest-vscode 0.2.35

I clicked Vitest: Enable assuming that was required...

ngirardin commented 1 year ago

I think that I found a fix: the problem seems to come from node not being installed globally, but by a version manager (in my case n).

Lauro235 commented 1 year ago

I think that I found a fix: the problem seems to come from node not being installed globally, but by a version manager (in my case n).

This makes perfect sense, I have nvm for windows, I wonder how many people share the same environment...

Just out of curiosity, what are the next steps in a case like this? Do people take it on themselves to try to fix the bug? Have you already done that? Apologies if that's a noob question!

bradenbiz commented 1 year ago

I think that I found a fix: the problem seems to come from node not being installed globally, but by a version manager (in my case n).

I can confirm this. I originally installed Node on my MacOS machine via NVM, and I was having this issue. I just went and downloaded the installer from https://nodejs.org/en/download/ and installed Node through the wizard.

Restarted VSCode a couple times, and now I'm getting test results in the UI!

ngirardin commented 1 year ago

Thanks for the reproduction. The issue is not limited to Windows, I'm having it on macOS as well.

As for the next step, I've created a PR (https://github.com/vitest-dev/vscode/pull/118), I'm waiting for the maintainers to review it.

lucaspereirasouzat commented 1 year ago

same problem here

JAKimball commented 1 year ago

Sorry, but the "fix" in PR #118 actually caused this to start happening again for me. I had to revert to the previous version (v0.2.36) in order to not get the above error.

Some details:

At some point in the past, I had set the setting remote.WSL.useShellEnvironment to false. ("If set [true], the WSL windows gets the environment from the shell it was opened from.")

For versions of the extension prior to the current (< v0.2.37), when I set remote.WSL.useShellEnvironment back to the default (true), the extension would identify the vitest version correctly, provided that VSCode was started from the Linux command line in the proper environment (as opposed to the Windows desktop where it would still fail).

For the current version (v0.2.37), I get Vitest version = undefined and Because Vitest version < 0.12.0 ... regardless of the remote.WSL.useShellEnvironment setting. Reverting to the previous extension version now fixes the problem for me.

ngirardin commented 1 year ago

Hi Jonathan,

(I'm not the maintainer, just a contributor)

I'm sorry that the change broke your setup.

I don't have any windows machine to reproduce the bug.

I don't know if there's a reliable way to determine when we should pass the process.execPath param or not (maybe there are some env variables that differ?).

We could maybe do it this way:

Lorentz, Braden, Lucas the fix was merged, does it now work on your end?

Best, Nicolas

On Fri, Jan 20, 2023 at 9:41 AM Jonathan Kimball @.***> wrote:

Sorry, but the "fix" in PR #118 https://github.com/vitest-dev/vscode/pull/118 actually caused this to start happening again for me. I had to revert to the previous version (v0.2.36) in order to not get the above error.

Some details:

  • I'm on Windows with Ubuntu 22.04 on WSL.
  • All installations of Node are managed via nvm.

At some point in the past, I had set the setting remote.WSL.useShellEnvironment to false. ("If set [true], the WSL windows gets the environment from the shell it was opened from.")

For versions of the extension prior to the current (< v0.2.37), when I set remote.WSL.useShellEnvironment back to the default (true), the extension would identify the vitest version correctly, provided that VSCode was started from the Linux command line in the proper environment (as opposed to the Windows desktop where it would still fail).

For the current version (v0.2.37), I get Vitest version = undefined and Because Vitest version < 0.12.0 ... regardless of the remote.WSL.useShellEnvironment setting. Reverting to the previous extension version now fixes the problem for me.

— Reply to this email directly, view it on GitHub https://github.com/vitest-dev/vscode/issues/88#issuecomment-1398074211, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAENRQHQVUTCKKICGZGD3VLWTJFTNANCNFSM6AAAAAAQYTBHZY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

aniketicloud commented 1 year ago

I am getting the same error on Windows.

ngirardin commented 1 year ago

Hi Aniket,

I'll try to work on a fix.

On Sun, Jan 22, 2023 at 9:20 AM Aniket Pandharabale < @.***> wrote:

I am getting the same error on Windows.

— Reply to this email directly, view it on GitHub https://github.com/vitest-dev/vscode/issues/88#issuecomment-1399428277, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAENRQEOQLJS56TORIPFMZLWTTUTBANCNFSM6AAAAAAQYTBHZY . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ngirardin commented 1 year ago

@JAKimball @aniketicloud, could you try https://github.com/vitest-dev/vscode/pull/125 to see if it fixes the issue?

- git clone https://github.com/ngirardin/vscode.git
- git checkout better-version-detection  
- npm install
- npm run compile
- Click on "Run and Debug", then in the panel select "Run Extension Base" and click on the play icon

A new VSCode window will open, try to open a few projects, and please let me know if the extensions detect the version.

asbermudez commented 1 year ago

@ngirardin Works with the project I was having issues :)

aniketicloud commented 1 year ago

@JAKimball @aniketicloud, could you try #125 to see if it fixes the issue?

- git clone https://github.com/ngirardin/vscode.git
- git checkout better-version-detection  
- npm install
- npm run compile
- Click on "Run and Debug", then in the panel select "Run Extension Base" and click on the play icon

A new VSCode window will open, try to open a few projects, and please let me know if the extensions detect the version.

ngirardin commented 1 year ago

Thank you guys, I'll submit the PR for review

mrcaidev commented 1 year ago

I set vitest.enable to true in .vscode/settings.json, and the extension is forced to open. The sidebar appears, but warnings are still there, and I cannot run tests in editor.

Looking forward to the fix!

OS: Arch WSL Extension version: v0.2.37

ngirardin commented 1 year ago

@mrcaidev did you tried the steps in https://github.com/vitest-dev/vscode/issues/88#issuecomment-1400769734 ?

mrcaidev commented 1 year ago

@mrcaidev did you tried the steps in #88 (comment) ?

npm run compile can't resolve birpc and flatted.

Error log ``` CLI Building entry: ./src/extension.ts CLI Using tsconfig: tsconfig.json CLI tsup v5.12.9 CLI Target: node12 CJS Build start ✘ [ERROR] Could not resolve "birpc" src/pure/watch/ws-client.ts:5:28: 5 │ import { createBirpc } from 'birpc' ╵ ~~~~~~~ You can mark the path "birpc" as external to exclude it from the bundle, which will remove this error. ✘ [ERROR] Could not resolve "flatted" src/pure/watch/ws-client.ts:6:33: 6 │ import { parse, stringify } from 'flatted' ╵ ~~~~~~~~~ You can mark the path "flatted" as external to exclude it from the bundle, which will remove this error. CJS Build failed Error: Build failed with 2 errors: src/pure/watch/ws-client.ts:5:28: ERROR: Could not resolve "birpc" src/pure/watch/ws-client.ts:6:33: ERROR: Could not resolve "flatted" ... ```
ngirardin commented 1 year ago

Did you run npm install first?

On Thu, Jan 26, 2023 at 4:30 AM Yuwang Cai @.***> wrote:

@mrcaidev https://github.com/mrcaidev did you tried the steps in #88 (comment) https://github.com/vitest-dev/vscode/issues/88#issuecomment-1400769734 ?

npm run compile can't resolve birpc and flatted. Error log

CLI Building entry: ./src/extension.ts

CLI Using tsconfig: tsconfig.json

CLI tsup v5.12.9

CLI Target: node12

CJS Build start

✘ [ERROR] Could not resolve "birpc"

src/pure/watch/ws-client.ts:5:28:

  5 │ import { createBirpc } from 'birpc'

    ╵                             ~~~~~~~

You can mark the path "birpc" as external to exclude it from the bundle, which will remove this

error.

✘ [ERROR] Could not resolve "flatted"

src/pure/watch/ws-client.ts:6:33:

  6 │ import { parse, stringify } from 'flatted'

    ╵                                  ~~~~~~~~~

You can mark the path "flatted" as external to exclude it from the bundle, which will remove this

error.

CJS Build failed

Error: Build failed with 2 errors:

src/pure/watch/ws-client.ts:5:28: ERROR: Could not resolve "birpc"

src/pure/watch/ws-client.ts:6:33: ERROR: Could not resolve "flatted"

...

— Reply to this email directly, view it on GitHub https://github.com/vitest-dev/vscode/issues/88#issuecomment-1404525551, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAENRQC4VAJMZIEJUQMAHFDWUHVWRANCNFSM6AAAAAAQYTBHZY . You are receiving this because you were mentioned.Message ID: @.***>

mrcaidev commented 1 year ago

Did you run npm install first?

Solved. I installed it with pnpm and somehow the dependencies broke, but with npm it works well.

And the extension works perfectly in the debug session. ❤️

ngirardin commented 1 year ago

Thanks, I'm glad to be here! I'm waiting for a maintainer to merge the pull request.

On Thu, Jan 26, 2023 at 9:34 AM Yuwang Cai @.***> wrote:

Did you run npm install first? … <#m3573095887877003356> On Thu, Jan 26, 2023 at 4:30 AM Yuwang Cai @.> wrote: @mrcaidev https://github.com/mrcaidev https://github.com/mrcaidev https://github.com/mrcaidev did you tried the steps in #88 https://github.com/vitest-dev/vscode/issues/88 (comment) <#88 (comment) https://github.com/vitest-dev/vscode/issues/88#issuecomment-1400769734> ? npm run compile can't resolve birpc and flatted. Error log CLI Building entry: ./src/extension.ts CLI Using tsconfig: tsconfig.json CLI tsup v5.12.9 CLI Target: node12 CJS Build start ✘ [ERROR] Could not resolve "birpc" src/pure/watch/ws-client.ts:5:28: 5 │ import { createBirpc } from 'birpc' ╵ ~~~ You can mark the path "birpc" as external to exclude it from the bundle, which will remove this error. ✘ [ERROR] Could not resolve "flatted" src/pure/watch/ws-client.ts:6:33: 6 │ import { parse, stringify } from 'flatted' ╵ ~~~~~ You can mark the path "flatted" as external to exclude it from the bundle, which will remove this error. CJS Build failed Error: Build failed with 2 errors: src/pure/watch/ws-client.ts:5:28: ERROR: Could not resolve "birpc" src/pure/watch/ws-client.ts:6:33: ERROR: Could not resolve "flatted" ... — Reply to this email directly, view it on GitHub <#88 (comment) https://github.com/vitest-dev/vscode/issues/88#issuecomment-1404525551>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAENRQC4VAJMZIEJUQMAHFDWUHVWRANCNFSM6AAAAAAQYTBHZY https://github.com/notifications/unsubscribe-auth/AAENRQC4VAJMZIEJUQMAHFDWUHVWRANCNFSM6AAAAAAQYTBHZY . You are receiving this because you were mentioned.Message ID: @.>

Solved. I installed it with pnpm and somehow the dependencies broke, but with npm it works well.

And the extension works perfectly in the debug session. ❤️

— Reply to this email directly, view it on GitHub https://github.com/vitest-dev/vscode/issues/88#issuecomment-1404690729, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAENRQBBQGZ6CWMVQXPZ4HDWUIZJTANCNFSM6AAAAAAQYTBHZY . You are receiving this because you were mentioned.Message ID: @.***>

mikestopcontinues commented 1 year ago

Not every workspace root in my project is a JS project. But I think I should still be able to use run/debug/watch in my JS workspace roots. Will #125 work for my case? I ask because the error message suggests it may not...

braebo commented 1 year ago

Is there a workaround for pnpm users while we wait for #125?

zxch3n commented 1 year ago

@ngirardin 's PR is merged and released now. Is it still happening? @JAKimball

ffxsam commented 1 year ago

Works great now, thanks!

CleanShot 2023-02-08 at 10 44 15
ngirardin commented 1 year ago

Thank you everyone for the feedback 🤗

pearone commented 1 year ago

pnpm +1

mrcaidev commented 1 year ago

Still an issue.

Version: v0.2.39 Environment: WSL2, pnpm monorepo Log:

[INFO 11:11:56 AM] Vitest Workspace [MY PROJECT NAME]: Vitest version = undefined
[Error 11:11:56 AM] Because Vitest version < 0.12.0 for every workspace folder, run/debug/watch tests from Vitest extension disabled.
liana-p commented 1 year ago

I'm also having this issue. using nvm for windows and pnpm

kwiniarski commented 1 year ago

Lately I had the same issue with latest extension and Vitest (Windows, fnm & pnpm). As my repository is a monorepo, I had Vitest installed in specific packages. The solution was to hoist Vitest to the root node_modules folder. You can do that with pnpm by adding public-hoist-pattern[]=*vitest* to your .npmrc file in the project root folder.

mrcaidev commented 1 year ago

Solved with Vitest Workspace:

import { defineWorkspace } from "vitest/config";

export default defineWorkspace(["packages/*", "apps/*"]);

And nothing else.

Plus, I installed Vitest in the monorepo root.

imanwarsame commented 1 year ago

Not working for me, I am not using a monorepo. Using windows. Error text reads as follows Because Vitest version < 0.12.0 for every workspace folder, run/debug/watch tests from Vitest extension disabled.

wighawag commented 1 year ago

I have having the same issue, no monorepo but pnpm

Khanh2050 commented 1 year ago

Seem like newest version bring back this issue - or at least on my Windows. When I downgrade back to 0.2.39 , the issue is gone and Vitest starti working normal again

Vikms95 commented 1 year ago

Seem like newest version bring back this issue - or at least on my Windows. When I downgrade back to 0.2.39 , the issue is gone and Vitest starti working normal again

Having this same issue, tried the steps above and I was not able to figure it out. I'll downgrade for now.

deka commented 1 year ago

related with https://github.com/vitest-dev/vscode/issues/116 ?

OrvilleTheDuck commented 1 year ago

I fixed this issue on Windows by moving my code from a path with spaces to one without.

When the extension calls vitest.cmd to get the version if the path has spaces in it the command fails.

Trying to get vitest version from c:\<Path To Code With Spaces>\node_modules\.bin\vitest.cmd -v...

Extension Version: 0.2.42 Vitest Version: 0.33.0 OS: Windows

borgmon commented 9 months ago

I am using n, pnpm, monorepo. I solved it by adding vitest to the root package.json and reloading the vscode window, in addition to this change

Solved with Vitest Workspace:

import { defineWorkspace } from "vitest/config";

export default defineWorkspace(["packages/*", "apps/*"]);

And nothing else.

Plus, I installed Vitest in the monorepo root.

aurelienbobenrieth commented 9 months ago

@keith-harrison-iopt Thank you my dear sir! I had the exact same issues, removed existing spaces from my dir path fixed it as well !

firatoezcan commented 8 months ago

If anyone stumbled upon this, I've debugged it for a really long time and at the end the issue was that the vitest command couldn't be ran because my project was using a postcss.config.js with type: "module".

If it somehow doesn't work in your workspace, try running this command to see if the server is even able to spin up properly:

./node_modules/.bin/vitest --api.port 39154 --api.host 127.0.0.1

If this fails, resolve those issues and reload the window when it runs without crashing