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

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

Closed
daple opened this issue Sep 29, 2022 · 47 comments
Closed

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

daple opened this issue Sep 29, 2022 · 47 comments
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@daple
Copy link

daple commented Sep 29, 2022

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

  • OS: [e.g. macOS]
  • VSCode version:
  • Vitest version:
  • Vitest plugin version:

Additional context
same setup on macos works

@daple daple added the p3-minor-bug An edge case that only affects very specific usage (priority) label Sep 29, 2022
@gaokun
Copy link

gaokun commented Sep 30, 2022

I got the same warning on MacOS

Vitest Plugin: 0.2.29
Vitest: 0.23.4
vscode: 1.17.2
MacOS: 11.4

@Ewocker
Copy link

Ewocker commented Oct 8, 2022

same warning on MacOS

@philwolstenholme
Copy link

philwolstenholme commented Oct 8, 2022

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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

@darioielardi
Copy link

Same here:
macOS 13.0.1
Vitest 0.25.2
vitest-vscode 0.2.34

@Lauro235
Copy link

Lauro235 commented Jan 3, 2023

Same here
Windows 11
Vitest 0.26.3
vitest-vscode 0.2.35

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

@ngirardin
Copy link
Contributor

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
Copy link

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
Copy link

bradenbiz commented Jan 13, 2023

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
Copy link
Contributor

ngirardin commented Jan 13, 2023

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 (#118), I'm waiting for the maintainers to review it.

@lucaspereirasouzat
Copy link

same problem here

@JAKimball
Copy link

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:

  • 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.

@ngirardin
Copy link
Contributor

ngirardin commented Jan 21, 2023 via email

@aniketicloud
Copy link

I am getting the same error on Windows.

@ngirardin
Copy link
Contributor

ngirardin commented Jan 22, 2023 via email

@ngirardin
Copy link
Contributor

ngirardin commented Jan 22, 2023

@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.

@asbermudez
Copy link

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

@aniketicloud
Copy link

@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.

  • I followed the same steps.
  • In vscode root folder, the Vitest plugin is not able to get the version.
  • When I did Run and Debug, then new VS Code opened. In this new window, I clicked on run the test (left side arrow in test file), but now test runs and are not stopping.

@ngirardin
Copy link
Contributor

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

@mrcaidev
Copy link

@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
Copy link
Contributor

ngirardin commented Jan 26, 2023 via email

@mrcaidev
Copy link

mrcaidev commented Jan 26, 2023

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
Copy link
Contributor

ngirardin commented Jan 26, 2023 via email

@mikestopcontinues
Copy link

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
Copy link

braebo commented Feb 4, 2023

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

@zxch3n
Copy link
Member

zxch3n commented Feb 8, 2023

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

@ffxsam
Copy link

ffxsam commented Feb 8, 2023

Works great now, thanks!

CleanShot 2023-02-08 at 10 44 15

@zxch3n zxch3n closed this as completed Feb 9, 2023
@ngirardin
Copy link
Contributor

Thank you everyone for the feedback 🤗

@pearone
Copy link

pearone commented Feb 21, 2023

pnpm +1

@mrcaidev
Copy link

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
Copy link

liana-p commented Apr 10, 2023

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

@kwiniarski
Copy link

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
Copy link

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
Copy link

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
Copy link

wighawag commented May 7, 2023

I have having the same issue, no monorepo but pnpm

@Khanh2050
Copy link

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
Copy link

Vikms95 commented Jun 13, 2023

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
Copy link

deka commented Jun 23, 2023

related with #116 ?

@OrvilleTheDuck
Copy link

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
Copy link

borgmon commented Dec 14, 2023

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
Copy link

@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
Copy link

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

@github-actions github-actions bot locked and limited conversation to collaborators Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

No branches or pull requests