From 5452296c6ec44a39b59efe2fef6ec28084093064 Mon Sep 17 00:00:00 2001 From: Damjan Cvetko Date: Thu, 6 Jan 2022 16:16:28 +0100 Subject: [PATCH 1/4] doc: Clarify path search in child_process spawn The documentation about command lookup could be more clear and note differences between Windows and Linux/OSX. Current text gives the impression that if one passes `options.env` without `PATH` that the path search will fall back on `process.env.PATH`. However in reality, passing environment without PATH to execvp causes it to look for the binary only in `/usr/bin:/bin`. Also Windows behaves different and more in line with the current documentation text. References: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/execvp.3.html https://linux.die.net/man/3/execvp https://github.com/nodejs/node/blob/c61870c376e2f5b0dbaa939972c46745e21cdbdd/deps/uv/src/unix/process.c#L337 https://github.com/nodejs/node/blob/c61870c376e2f5b0dbaa939972c46745e21cdbdd/deps/uv/src/win/process.c#L1017 --- doc/api/child_process.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index c457ac8aa34c8e..5bc9e3d427432b 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -36,8 +36,10 @@ identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }` option if the output will not be consumed. The command lookup is performed using the `options.env.PATH` environment -variable if it is in the `options` object. Otherwise, `process.env.PATH` is -used. +variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is +used. If `options.env` is set, but without `PATH`, lookup on UNIX is performed +on a default search path search of `/usr/bin:/bin` (see execvpe/execvp), on Windows +the current processes environment variable `PATH` is used. On Windows, environment variables are case-insensitive. Node.js lexicographically sorts the `env` keys and uses the first one that From ac0d1bc05de0f55046a6eceef8685f21dab8edc8 Mon Sep 17 00:00:00 2001 From: Damjan Cvetko Date: Fri, 7 Jan 2022 00:06:15 +0100 Subject: [PATCH 2/4] Update doc/api/child_process.md Co-authored-by: Tierney Cyren --- doc/api/child_process.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 5bc9e3d427432b..7b67ab80d311b5 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -37,7 +37,7 @@ option if the output will not be consumed. The command lookup is performed using the `options.env.PATH` environment variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is -used. If `options.env` is set, but without `PATH`, lookup on UNIX is performed +used. If `options.env` is set without `PATH`, lookup on UNIX is performed on a default search path search of `/usr/bin:/bin` (see execvpe/execvp), on Windows the current processes environment variable `PATH` is used. From dbe8bcd03417c63f9852bb5e78243eb076cdb952 Mon Sep 17 00:00:00 2001 From: Damjan Cvetko Date: Tue, 11 Jan 2022 14:29:21 +0100 Subject: [PATCH 3/4] Update child_process.md --- doc/api/child_process.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 7b67ab80d311b5..5c7369dbf91419 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -37,9 +37,10 @@ option if the output will not be consumed. The command lookup is performed using the `options.env.PATH` environment variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is -used. If `options.env` is set without `PATH`, lookup on UNIX is performed -on a default search path search of `/usr/bin:/bin` (see execvpe/execvp), on Windows -the current processes environment variable `PATH` is used. +used. If `options.env` is set without `PATH`, lookup on Unix is performed +on a default search path search of `/usr/bin:/bin` (see your operating systems +manual for execvpe/execvp), on Windows the current processes environment +variable `PATH` is used. On Windows, environment variables are case-insensitive. Node.js lexicographically sorts the `env` keys and uses the first one that From 591bc3d571046cfcb596f8400f1fe6ef5bada005 Mon Sep 17 00:00:00 2001 From: Damjan Cvetko Date: Thu, 13 Jan 2022 07:25:42 +0100 Subject: [PATCH 4/4] Update doc/api/child_process.md Language fix. Co-authored-by: Rich Trott --- doc/api/child_process.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 5c7369dbf91419..fe25417a81a2c1 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -38,7 +38,7 @@ option if the output will not be consumed. The command lookup is performed using the `options.env.PATH` environment variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is used. If `options.env` is set without `PATH`, lookup on Unix is performed -on a default search path search of `/usr/bin:/bin` (see your operating systems +on a default search path search of `/usr/bin:/bin` (see your operating system's manual for execvpe/execvp), on Windows the current processes environment variable `PATH` is used.