Vitest not starting up due to failed version check on windows
daple opened this issue ยท 44 comments
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.
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
I got the same warning on MacOS
Vitest Plugin: 0.2.29
Vitest: 0.23.4
vscode: 1.17.2
MacOS: 11.4
same warning on MacOS
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
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
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.
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
Same, doesn't run tests on OS X Ventura.
Same here:
macOS 13.0.1
Vitest 0.25.2
vitest-vscode 0.2.34
Same here
Windows 11
Vitest 0.26.3
vitest-vscode 0.2.35
I clicked Vitest: Enable assuming that was required...
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 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!
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!
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.
same problem here
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.
I am getting the same error on Windows.
@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 Works with the project I was having issues :)
@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.
Thank you guys, I'll submit the PR for review
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
@mrcaidev did you tried the steps in #88 (comment) ?
@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"
...
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. โค๏ธ
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...
@ngirardin 's PR is merged and released now. Is it still happening? @JAKimball
Thank you everyone for the feedback ๐ค
pnpm +1
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.
I'm also having this issue. using nvm for windows and pnpm
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.
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.
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.
I have having the same issue, no monorepo but pnpm
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
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.
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