execa: execa does not respect $PATH variable
I have two installations of git and execa
seems to pick the wrong one, not respecting $PATH
correctly, while child-process
does it correctly (even if I explicitly remove /usr/bin
from $PTAH
and add my desired path twice, once in the beginning and once in the end):
$ /usr/bin/git --version
git version 1.8.3.1
$ /opt/rh/rh-git29/root/usr/bin/git --version
git version 2.9.3
$ echo $PATH
/opt/rh/rh-git29/root/usr/bin:/bin:/usr/local/bin:/opt/rh/rh-git29/root/usr/bin
$ cat ./index.js
const execa = require('execa');
(async () => {
const {stdout} = await execa('git', ['--version']);
console.log(stdout);
//=> 'unicorns'
})();
const execFile = require('child_process').execFile;
const child = execFile('git', ['--version'], (error, stdout, stderr) => {
if (error) {
console.error('stderr', stderr);
throw error;
}
console.log('stdout', stdout);
});
$ node ./index.js
git version 1.8.3.1
stdout git version 2.9.3
I am missing something here?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 15 (1 by maintainers)
Commits related to this issue
- Bug 1560193 - Always specify the Python executable to use when running `./mach browsertime` r=nalexander If `./mach browsertime` runs browsertime with a globally-installed node, due to an existing bu... — committed to mozilla/gecko-dev by brennie 5 years ago
- Bug 1560193 - Always specify the Python executable to use when running `./mach browsertime` r=nalexander If `./mach browsertime` runs browsertime with a globally-installed node, due to an existing bu... — committed to xeonchen/gecko by brennie 5 years ago
- Bug 1560193 - Always specify the Python executable to use when running `./mach browsertime` r=nalexander If `./mach browsertime` runs browsertime with a globally-installed node, due to an existing bu... — committed to marco-c/gecko-dev-comments-removed by marco-c 5 years ago
- Bug 1560193 - Always specify the Python executable to use when running `./mach browsertime` r=nalexander If `./mach browsertime` runs browsertime with a globally-installed node, due to an existing bu... — committed to marco-c/gecko-dev-wordified by marco-c 5 years ago
- Bug 1560193 - Always specify the Python executable to use when running `./mach browsertime` r=nalexander If `./mach browsertime` runs browsertime with a globally-installed node, due to an existing bu... — committed to marco-c/gecko-dev-wordified-and-comments-removed by marco-c 5 years ago
@lucasbraun If I understood your problem correctly, using the
preferLocal: false
option should solve it, could you confirm this?We are considering changing its default value from
true
tofalse
(#314).@ammarbinfaisal
childProcess.spawn()
is the base for all otherchildProcess
methods variants includingexecFile()
. See the Node.js source.