[BUG] `process.env.PATH` can be undefined on Windows
Nessuno ha ancora preso questa issue.
- #182 di @amtbsl — chiusa senza merge
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, node.js
- Ambito
- cli
Direzione di ricerca
Start with the repro.js script and reproduce the differing process.env.PATH behavior between the main thread and Worker on Windows. Then trace which's PATH lookup and consider the reported process.env.Path case without changing Unix behavior. Done means which resolves executables in the described Windows worker scenario and the reproduction no longer fails.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
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 / c7a1ac924074d4cf246a3d96f33f7ee350142fcc, 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 c7a1ac924074d4cf246a3d96f33f7ee350142fcc).
Steps To Reproduce
- On windows
- With this script (or this project):
// file: repro.js import * as process from "node:process"; import { Worker, isMainThread } from 'node:worker_threads'; if (isMainThread) { console.log("[MAIN]", "PATH:", process.env.PATH); new Worker("./repro.js"); } else { console.log("[WORK]", "PATH:", process.env.PATH); } - Run
node repro.jsfrom PowerShell or CMD in Windows Terminal (Windows 11) or PowerShell/Command prompt (earlier Windows versions). - Observe that the
[MAIN] PATH:prints the full path but the[WORK] PATH:is undefined.
Environment
- npm: v9.8.1
- Node: v18.16.1
- OS: Windows 11 Home (22H2)
- platform: Virtual Machine (LXC)
- Lingua principale
- JavaScript
- Stelle
- 352
- Fork
- 55
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di npm/node-which
-
Distribute esm versionAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
npm/node-which#174 · 2 commenti · 1 reazione ·
-
[BUG] EACCES Error with Windows 11 App Execution AliasesForse già presa @dyk1454683243-sudo l’ha presa 22 giorni fa. ApertaNeeds Triage
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
npm/node-which#157 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
npm/node-which#133 · 1 commento ·
-
Failed to parse past path entries on D:Forse già presa @dyk1454683243-sudo l’ha presa 22 giorni fa. Apertabug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
npm/node-which#56 · 1 commento ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 32/100
npm/node-which#50 · 1 commento ·
Tutte le issue di npm/node-which
Issue simili
-
Language MVP task
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
saayam-for-all/webapp#1914 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Dev image build fails: `npm install` in the root Dockerfile runs out of memory (exit 134)Forse già presa @andest01 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
good first issue hacktoberfest help wanted
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 76/100
pacocartones/free-llm-api-hub#262 ·
I maintainer di solito rispondono entro 1 giorno
-
agent-task risk:low
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
guyellis/http-status-check#512 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
microsoft/playwright#43327 ·
I maintainer di solito rispondono entro 1 giorno