Skip to content

execa does not respect $PATH variable #153

@lucasbraun

Description

@lucasbraun

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?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions