vitest-jetbrains-plugin icon indicating copy to clipboard operation
vitest-jetbrains-plugin copied to clipboard

0.6.6: error when running from intellij on windows

Open simonmarshall opened this issue 3 years ago • 13 comments

thanks for the plugin!

when running a test from intellij with the plugin version 0.5.0, i get:

Snag_53078fd

i couldn't figure out how to force it to use vitest.cmd either (if that is the solution).

simonmarshall avatar Jul 29 '22 16:07 simonmarshall

Maybe a bug caused by .cmd ext name. Could you try attached version? vitest-jetbrains-plugin-0.5.0.zip

linux-china avatar Jul 29 '22 20:07 linux-china

hi @linux-china - thanks, this seems to be fixed in 0.5.1 which i updated via ij plugins

simonmarshall avatar Aug 01 '22 08:08 simonmarshall

ooi, where is the code hosted for Vitest Runner 0.5.1? this repo doesn't seem to correspond to it

simonmarshall avatar Aug 01 '22 08:08 simonmarshall

hi @linux-china - unfortunately this issue is back with 0.6.3:

Error running 'vitest run -t "foo" src/components/bar.spec.ts': Cannot run program "C:\Program" (in directory "C:\Users\Foo\bar"): CreateProcess error=2, The system cannot find the file specified

looks like "Program Files" is unquoted

simonmarshall avatar Aug 23 '22 13:08 simonmarshall

@simonmarshall yes, my bad. I have no Windows development, and a developer reported a bug with WSL on Windows. Could you post your os info, NODE_PATH and correct command to run Vitest tests? thanks.

linux-china avatar Aug 23 '22 16:08 linux-china

hi @linux-china

  • os is Win10 enterprise 20H2
  • node is C:\Program Files\nodejs\node.exe (note the space)
  • i suspect you're running the correct command args, but you need to wrap the path to node.exe with double quotes to prevent spaces being interpreted as arg separators, ie, "C:\Program Files\nodejs\node" vitest..., if you don't want to just use node vitest... and trust that node is in the PATH

does that help?

simonmarshall avatar Aug 24 '22 12:08 simonmarshall

@simonmarshall could you have a test with other NOD_HOME without space, such as c:\node. I should confirm it was caused by space in path or cmd ext name. thanks

linux-china avatar Aug 24 '22 16:08 linux-china

i'm not sure how i can do that, i'm just clicking on the green triangle in ij, there is no NODE_HOME defined in my env

i can confirm that if i try to run C:\Program Files\nodejs\node.exe vitest run -t ... in a cmd window, then i get the error: 'C:\Program' is not recognized as an internal or external command, operable program or batch file.

(same if i try to run C:\Program Files\nodejs\node vitest run -t ...)

and you can see above, if i run try to run via ij, then i get the error: Error running 'vitest run -t "foo" src/components/bar.spec.ts': Cannot run program "C:\Program" (in directory "C:\Users\Foo\bar"): CreateProcess error=2, The system cannot find the file specified

suggesting that it thinks i'm trying to run C:\Program and not C:\Program Files\nodejs\node.no-such-ext

(i'm assuming it's trying to run node, and run it with something like the above args, but i can't be sure ofc, since i can only see C:\Program part of the path)

simonmarshall avatar Aug 24 '22 16:08 simonmarshall

Could you assign node ad npm path for project and have test?

image

linux-china avatar Aug 24 '22 20:08 linux-china

ok, if i use an unzipped nodejs download, like so: image

then the test fails differently: Error running 'vitest run -t "foo" src/bar.spec.ts': Cannot run program "C:\Users\foo\Downloads\node-v16.17.0-win-x64\node_modules\npm" (in directory "C:\Users\foo\bar"): CreateProcess error=5, Access is denied which suggests the earlier issue was due to unquoted path whitespace, at least

but, note that C:\Users\foo\Downloads\node-v16.17.0-win-x64\node_modules\npm is not a program, it's a folder containing npm's bin, lib, etc

if i force change the package manager path to C:\Users\foo\Downloads\node-v16.17.0-win-x64\node_modules\npm\bin\npm.cmd like so: image

then i get this:

C:\Users\foo\Downloads\node-v16.17.0-win-x64\node_modules\npm\bin\npm.cmd exec -- vitest run -t "foo" src/bar.spec.ts
node:internal/modules/cjs/loader:959
  throw err;
  ^

Error: Cannot find module 'C:\Users\foo\Downloads\node-v16.17.0-win-x64\node_mo
dules\npm\bin\node_modules\npm\bin\npm-cli.js'
�[90m    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:9
56:15)�[39m
�[90m    at Function.Module._load (node:internal/modules/cjs/loader:804:27)�[39m

�[90m    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/r
un_main:81:12)�[39m
�[90m    at node:internal/main/run_main_module:17:47�[39m {
  code: �[32m'MODULE_NOT_FOUND'�[39m,
  requireStack: []
}

fwiw, if i set lang frameworks to a node interpreter that i then delete from the file system, then the test works successfully, since it runs npm.cmd exec -- vitest run -t ... instead

simonmarshall avatar Aug 25 '22 09:08 simonmarshall

Next week, I will find a Windows laptop and fix this problem.

linux-china avatar Aug 27 '22 23:08 linux-china

hi @linux-china - any luck sourcing a windows laptop?

0.6.6 still fails for me in the same way - looking like it's due to unquoted path whitespace

Error running 'vitest run -t "xxx" src/yyy.spec.ts': Cannot run program "C:\Program" (in directory "C:\Users\zzz"): CreateProcess error=2, The system cannot find the file specified

simonmarshall avatar Oct 05 '22 16:10 simonmarshall

hi @linux-china,

I have the same problem using Windows + WSL

Cannot run program "\home\user\.nvm\versions\node\v16.17.1\bin\yarn" (in directory "\\wsl$\Ubuntu20.04LTS\home\user\workspace\project"): CreateProcess error=2, The system cannot find the file specified

Have you planned a fix?

Best regards,

Mysh3ll avatar Oct 17 '22 08:10 Mysh3ll