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

env issues on MacOS #526

Closed
hedefalk opened this issue Nov 25, 2019 · 3 comments · Fixed by #777
Closed

env issues on MacOS #526

hedefalk opened this issue Nov 25, 2019 · 3 comments · Fixed by #777

Comments

@hedefalk
Copy link

hedefalk commented Nov 25, 2019

No matter my settings I get some version of ENOENT when vscode-jest spawns. The issue is that neither node nor npm is on the path in whatever context that gets spawned.

Looking at vscode docs it seems that this should be honoured:
"terminal.integrated.automationShell.osx": "/usr/local/Cellar/fish/3.0.2/bin/fish",

but it doesn't seem to be. However, I have npm and node binaries in my path for all shells, bash, zsh and fish so probably not the root issue. I remember I had problems with MacOS and env in atom/vscoce a few years back, but I think it has been smooth for quite some time now.

I also do start vscode from command line. So it should inherit env, no?

I use nvm and I've tried running with:

npm test --
nvm use 10; npm test --
node_modules/.bin/jest

Nothing works. No binaries are present.

Environment

  1. node -v: ❯ v10.17.0

  2. npm -v: 6.13.1

  3. npm ls jest or npm ls react-scripts (if you haven’t ejected): jest@24.9.0

  4. Operating system: MacOS 10.15.1 (19B88)

Prerequisite

  • are you able to run jest test from command line? yes
  • npm run test

Expected Behavior

Tests running :)

Actual Behavior


Exception raised: Process failed: spawn npm ENOENT
Finished running all tests. Starting watch mode.

Exception raised: Process failed: spawn npm ENOENT

Exception raised: Process failed: spawn npm ENOENT

Exception raised: Process failed: spawn npm ENOENT

Exception raised: Process failed: spawn npm ENOENT

Exception raised: Process failed: spawn npm ENOENT
Starting Jest in Watch mode failed too many times and has been stopped.
Consider add this workspace folder to disabledWorkspaceFolders
 see troubleshooting: https://github.com/jest-community/vscode-jest/blob/master/README.md#troubleshooting

And from devtools:

console.ts:137 [Extension Host] spawning process with command=npm, args=test,--,--testLocationInResults,--json,--useStderr,--outputFile,/var/folders/kd/z0qzgl6x20dfwk3n3ny2wz8w0000gn/T/jest_runner.json,--watch,--no-color,--config,/Users/viktor.hedefalk/[my project****]/jest.config.js
notificationsAlerts.ts:40 Starting Jest in Watch mode failed too many times and has been stopped. Consider add this workspace folder to disabledWorkspaceFolders
--- 
@connectdotz
Copy link
Collaborator

the env and ENOENT issues have come up quite a bit, let's see if we can nail them:

vscode-jest spawn a child_process to run jest (or custom jest.pathToJest) on user's behave. The spawned process's env is based on process.env.

You can see it might not use your favor shell's env but the one specified in environ(7). You can try man environ to see how you can view and customize the env on your platform. Let me know how it goes.

@hedefalk
Copy link
Author

hedefalk commented Nov 26, 2019

Not sure I follow, shouldn't the env be inherited if I start code from cli? My env.shell is zsh, but that shouldn't really matter as long as I have a PATH containing the binaries at hand in the env that started code? env is chained through, right? I mean I can start do bash -> fish -> zsh and keep my PATH.

Either way, I've tried:

setenv SHELL (which fish)`
code

And I still get the same behaviour. I do have env.PATH containing the binaries that this plugin can't spawn:

❯ which npm
/Users/viktor.hedefalk/.config/nvm/10.17.0/bin/npm

❯ env | grep nvm
NVM_DIR=/Users/viktor/.nvm
PATH=/Users/viktor.hedefalk/.jabba/jdk/adopt@1.8.0-232/Contents/Home/bin:/Users/viktor.hedefalk/.nix-profile/bin:/Users/viktor.hedefalk/.config/nvm/10.17.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/viktor.hedefalk/.nix-profile/bin

@connectdotz
Copy link
Collaborator

please see #741 (comment)

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

Successfully merging a pull request may close this issue.

2 participants