direnv / direnv-vscode

unclutter your .profile
https://marketplace.visualstudio.com/items?itemName=mkhl.direnv
BSD Zero Clause License
157 stars 11 forks source link

Problem where env has been set after other extensions read the environment #725

Open thernstig opened 6 months ago

thernstig commented 6 months ago

There is a long standing issue here, see https://github.com/microsoft/vscode-eslint/issues/1596. I hope you have the stamina to read it.

Basically the extension vscode-eslint has a setting "eslint.runtime": "node" that is set in the workspace settings .vscode/settings.json . It means it reads the node version from the environment.

We load the node version via direnv. I think this comment best sums it up: https://github.com/microsoft/vscode-eslint/issues/1596#issuecomment-1948343747

Apparently the ESLint server, or any extension, inherits the environment from the extension host. It seems there is a race condition where direnv-vscode has not updated the enviroment, meaning that e.g. eslint-vscode cannot find the node version as it is in in the PATH.

I added a question in that thread as well that maybe the extension host itself should have an event if the environment is reloaded in some sense, so that it could be emitted so that all extensions could listen for it, and restart if needed or similar. Not sure if that is a good idea or not, but throwing it out here as well.