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

Always getting Error: spawn ENOTDIR when opening a workspace that has Vitest #383

Open
garyking opened this issue May 13, 2024 · 11 comments

Comments

@garyking
Copy link

Describe the bug

I open a workspace in VSC that has Vitest. I get the error as seen below.

The issue starts with v0.8.0 of this extension. So I'm using 0.6.3 for now. Presumably caused by this change.

Is there something I can change to fix this on my end? I've got Node installed globally on my Mac, v20.11.0, at /usr/local/bin/node. I don't use nvm.

Otherwise, the extension still seems to work fine.

This issue seems different from #381 since I don't use NVM.

Reproduction

  • Open a workspace in VSC that has Vitest.

Output

[INFO 3:49:04 PM] [v0.10.2] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 3:49:05 PM] [API] Running Vitest: v1.6.0 (vitest.config.ts)
[Error 3:49:06 PM] [Error Error] spawn ENOTDIR
Error: spawn ENOTDIR
    at ChildProcess.spawn (node:internal/child_process:414:11)
    at spawn (node:child_process:799:9)
    at /Users/gary/.vscode/extensions/vitest.explorer-0.10.2/dist/extension.js:18:186
    at new Promise (<anonymous>)
    at mf (/Users/gary/.vscode/extensions/vitest.explorer-0.10.2/dist/extension.js:18:112)
    at Rt (/Users/gary/.vscode/extensions/vitest.explorer-0.10.2/dist/extension.js:16:871)
    at gf (/Users/gary/.vscode/extensions/vitest.explorer-0.10.2/dist/extension.js:18:3887)
    at vf (/Users/gary/.vscode/extensions/vitest.explorer-0.10.2/dist/extension.js:21:683)
    at to (/Users/gary/.vscode/extensions/vitest.explorer-0.10.2/dist/extension.js:18:3390)
    at gr.defineTestProfiles (/Users/gary/.vscode/extensions/vitest.explorer-0.10.2/dist/extension.js:27:2375)
    at gr.activate (/Users/gary/.vscode/extensions/vitest.explorer-0.10.2/dist/extension.js:27:5404)
    at ed (/Users/gary/.vscode/extensions/vitest.explorer-0.10.2/dist/extension.js:27:759)
    at h.n (/Applications/Development/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:143:6281)
    at h.m (/Applications/Development/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:143:6244)
    at h.l (/Applications/Development/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:143:5701)


### Version

0.10.2

### Validations

- [X] Check that you are using the latest version of the extension
- [X] Check that there isn't [already an issue](https://github.com/vitest-dev/vscode/issues) that reports the same bug to avoid creating a duplicate.
- [X] Check that this is a concrete bug. For Q&A open a [GitHub Discussion](https://github.com/vitest-dev/vscode/discussions) or join our [Discord Chat Server](https://chat.vitest.dev).
- [X] The provided reproduction is a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) of the bug.
@ffMathy
Copy link
Collaborator

ffMathy commented May 13, 2024

I get this too. But only sporadically. When I then run a particular test again, it sometimes passes, but not always.

My tests use dotenv. Is that the same for you?

@garyking
Copy link
Author

I don't use dotenv.

@ffMathy
Copy link
Collaborator

ffMathy commented May 16, 2024

Alright, so unrelated to dotenv. No idea why it is happening then. The weird part is even that if I run all my tests, sometimes it'll happen only for a subset of the tests.

So hard to repro though 😄

@sheremet-va
Copy link
Member

Do you have Node available globally? What shell do you use by default? What does which node return when you run it from the working directory?

@ffMathy
Copy link
Collaborator

ffMathy commented May 17, 2024

When I run which node, it returns /usr/local/bin/node. So I suppose it is available globally. The version seems to be v20.13.1 currently.

I am running inside a DevContainer. The image is based on the node:lts base image.

@garyking
Copy link
Author

garyking commented May 17, 2024

Do you have Node available globally? What shell do you use by default? What does which node return when you run it from the working directory?

Yes I have Node available globally. which node returns /usr/local/bin/node. I'm using Node v20.11.0. The shell I use is Bash. I'm not using Dev Containers. I'm on MacOS Sonoma 14.4.1.

@garyking
Copy link
Author

This comment put me on the right path. If I open a .code-workspace file through Mac Finder, then the error appears. If I open the file through Bash with code Finder.code-workspace then the error does not appear.

I normally open VSC workspace files through the Finder, so I'd appreciate if that's fixed, thanks!

@ffMathy
Copy link
Collaborator

ffMathy commented May 17, 2024

I am not using workspaces at all. But for me it also only happens sporadically. When it happens, I just have to retry running the test a couple of more times, and it'll work again.

@sheremet-va
Copy link
Member

Is reported output the full output? I don't understand why it doesn't report the current PATH or Starting Vitest process with Node.js string

@sheremet-va
Copy link
Member

Added more logs in 0.10.6

@garyking
Copy link
Author

Posted new logs here, Unable to find 'node' executable. seems pretty relevant, it's not looking in /usr/local/bin/ for node apparently.

[INFO 3:30:40 PM] [v0.10.7] Vitest extension is activated because Vitest is installed or there is a Vite/Vitest config file in the workspace.
[INFO 3:30:40 PM] [API] Running Vitest: v1.6.0 (vitest.config.ts)
[Error 3:30:41 PM] [SPAWN] /bin/bash [Error Error] spawn ENOTDIR
Error: spawn ENOTDIR
    at ChildProcess.spawn (node:internal/child_process:414:11)
    at spawn (node:child_process:799:9)
    at /Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:18:496
    at new Promise (<anonymous>)
    at gf (/Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:18:414)
    at Rt (/Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:16:871)
    at vf (/Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:18:4257)
    at Ef (/Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:21:683)
    at so (/Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:18:3760)
    at Er.defineTestProfiles (/Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:27:2375)
    at Er.activate (/Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:27:5404)
    at sd (/Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:27:759)
    at h.n (/Applications/Development/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:143:6281)
    at h.m (/Applications/Development/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:143:6244)
    at h.l (/Applications/Development/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:143:5701)
[Error 3:30:41 PM] Unable to find 'node' executable.
Make sure to have Node.js installed and available in your PATH.
Current PATH: '/usr/bin:/bin:/usr/sbin:/sbin'.
[Error 3:30:41 PM] [Error Error] Unable to find 'node' executable.
Make sure to have Node.js installed and available in your PATH.
Current PATH: '/usr/bin:/bin:/usr/sbin:/sbin'.
Error: Unable to find 'node' executable.
Make sure to have Node.js installed and available in your PATH.
Current PATH: '/usr/bin:/bin:/usr/sbin:/sbin'.
    at Rt (/Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:18:56)
    at vf (/Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:18:4257)
    at Ef (/Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:21:683)
    at so (/Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:18:3760)
    at Er.defineTestProfiles (/Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:27:2375)
    at Er.activate (/Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:27:5404)
    at sd (/Users/gary/.vscode/extensions/vitest.explorer-0.10.7/dist/extension.js:27:759)
    at h.n (/Applications/Development/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:143:6281)
    at h.m (/Applications/Development/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:143:6244)
    at h.l (/Applications/Development/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:143:5701)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants