Skip to content

Commit 96dc591

Browse files
zobobengl
authored andcommitted
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`, the path search will fall back on `process.env.PATH`. 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. PR-URL: #41418 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent dfdce7c commit 96dc591

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: doc/api/child_process.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }`
3636
option if the output will not be consumed.
3737

3838
The command lookup is performed using the `options.env.PATH` environment
39-
variable if it is in the `options` object. Otherwise, `process.env.PATH` is
40-
used.
39+
variable if `env` is in the `options` object. Otherwise, `process.env.PATH` is
40+
used. If `options.env` is set without `PATH`, lookup on Unix is performed
41+
on a default search path search of `/usr/bin:/bin` (see your operating system's
42+
manual for execvpe/execvp), on Windows the current processes environment
43+
variable `PATH` is used.
4144

4245
On Windows, environment variables are case-insensitive. Node.js
4346
lexicographically sorts the `env` keys and uses the first one that

0 commit comments

Comments
 (0)