You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which might fail to resolve the executable on Windows in a threaded context (e.g. a Worker threads) due to PATH being undefined, instead being accessible (only) as Path.
Prior work on this topic in this project exists, starting with #34. It suggests there used to be an alternative lookup, but it was removed for a different reason (as I understand it). The removal happened in #35 / c7a1ac9, stating that:
Reading from a Path environ on Unix systems sometimes causes strange behavior
which is too cryptic for me to understand 😅 Nevertheless, it seems like a fair concern so I think a solution to the problems should take it into account. I'd also like to point out that issues on the Node.js repository on this topic suggest PATH being undefined is 1) known behavior, and 2) not considered a bug.
Running the reproducing script (see below) myself in various settings, I must admit I was not able to reproduce this issue with 100% accuracy. It somehow seems to depend on the terminal in which I run the script, in particular: I can reproduce it using the Windows terminal with both CMD and PowerShell (but not bash, coming with git for Windows) but not with any shell in the VSCode embedded terminal...
Expected Behavior
which does not fail to resolve the executable on Windows if PATH is undefined.
My suggestion would be to consider process.env.Path when process.env.PATH is undefined, possibly conditionally on whether which is running on Windows (per c7a1ac9).
Is there an existing issue for this?
Current Behavior
which
might fail to resolve the executable on Windows in a threaded context (e.g. a Worker threads) due toPATH
being undefined, instead being accessible (only) asPath
.Prior work on this topic in this project exists, starting with #34. It suggests there used to be an alternative lookup, but it was removed for a different reason (as I understand it). The removal happened in #35 / c7a1ac9, stating that:
which is too cryptic for me to understand 😅 Nevertheless, it seems like a fair concern so I think a solution to the problems should take it into account. I'd also like to point out that issues on the Node.js repository on this topic suggest
PATH
being undefined is 1) known behavior, and 2) not considered a bug.Running the reproducing script (see below) myself in various settings, I must admit I was not able to reproduce this issue with 100% accuracy. It somehow seems to depend on the terminal in which I run the script, in particular: I can reproduce it using the Windows terminal with both CMD and PowerShell (but not bash, coming with git for Windows) but not with any shell in the VSCode embedded terminal...
Expected Behavior
which
does not fail to resolve the executable on Windows ifPATH
is undefined.My suggestion would be to consider
process.env.Path
whenprocess.env.PATH
is undefined, possibly conditionally on whetherwhich
is running on Windows (per c7a1ac9).Steps To Reproduce
node repro.js
from PowerShell or CMD in Windows Terminal (Windows 11) or PowerShell/Command prompt (earlier Windows versions).[MAIN] PATH:
prints the full path but the[WORK] PATH:
is undefined.Environment
The text was updated successfully, but these errors were encountered: