-
-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
execa does not respect $PATH variable #153
Comments
@lucasbraun This doesn't appear to be problem with execa. execa is an alternative to childProcess.spawn(actually better than using it) and you shouldn't compare execFile's output with execa. Try using childProcess.spawn instead of execa and it would show the same result. Also, have a look at this nodejs/node#12986 |
@ammarbinfaisal |
@lucasbraun There has been few changes to the code handling Also could you try the following code instead? const execa = require('execa');
const childProcess = require('child_process');
console.log(execa.sync('echo $PATH', { shell: true }).stdout)
console.log(childProcess.spawnSync('echo $PATH', { shell: true, encoding: 'utf8' }).stdout) If all goes fine:
Also never forget to submit your environment information when submitting an issue as
|
Thanks, @ehmicky for your help with this. Unfortunately, the problem remains. I just checked with
Here is my environment:
I guess that it might be reproduce the problem on my OS, but I don't see why this should be an OS-specific problem. The problem should be reproducible on any OS where you install more than one version of git. |
You never know when a problem might be OS-specific unless you're very familiar with the implementation code, so it's better to be on the safe side :) Also the Node.js version is always a good idea to include in any GitHub issue. Just to be 100% sure, could you please paste your code above but with |
Also could you:
If my intuition is correct, I think this bug might be related to sindresorhus/npm-run-path#3 |
Yes, I can :-)
|
I think the PR I just opened here: sindresorhus/npm-run-path#5 should solve your problem. This needs to be reviewed by @sindresorhus first though. |
OK, thanks a lot! Looking forward to see whether it does fix the problem. That would be awesome! |
I think the issue here is that Until the PR is merged, using |
I thought of a way to move forward with this: see sindresorhus/npm-run-path#5 (comment) |
@lucasbraun If I understood your problem correctly, using the We are considering changing its default value from |
Yes, it does. Thanks a lot for fixing! |
Closing this thanks to #314. |
…g `./mach browsertime` r=nalexander If `./mach browsertime` runs browsertime with a globally-installed node, due to an existing bug in [execa][1], the wrong Python will be executed. We now specify the full path of the Python binary we wish to use (via the `PYTHON` environment variable that our fork of browsertime supports) and avoid this issue altogether. [1]: sindresorhus/execa#153 Differential Revision: https://phabricator.services.mozilla.com/D35374 --HG-- extra : moz-landing-system : lando
…g `./mach browsertime` r=nalexander If `./mach browsertime` runs browsertime with a globally-installed node, due to an existing bug in [execa][1], the wrong Python will be executed. We now specify the full path of the Python binary we wish to use (via the `PYTHON` environment variable that our fork of browsertime supports) and avoid this issue altogether. [1]: sindresorhus/execa#153 Differential Revision: https://phabricator.services.mozilla.com/D35374
My solution: export PATH I see that the original poster uses Software Collections. I've run into the very same issue with fish and It seems to be a trick of fish shell: > python3 -c 'import os; print(os.environ["PATH"])'
/home/user/.local/bin/:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
> set -g -p PATH /truc
> python3 -c 'import os; print(os.environ["PATH"])'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.7/os.py", line 678, in __getitem__
raise KeyError(key) from None
KeyError: 'PATH'
> set -x -p PATH /truc
> python3 -c 'import os; print(os.environ["PATH"])'
/truc:/truc:/home/user/.local/bin/:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games Node has (fortunately) the same behavior. And if for some reason, |
…g `./mach browsertime` r=nalexander If `./mach browsertime` runs browsertime with a globally-installed node, due to an existing bug in [execa][1], the wrong Python will be executed. We now specify the full path of the Python binary we wish to use (via the `PYTHON` environment variable that our fork of browsertime supports) and avoid this issue altogether. [1]: sindresorhus/execa#153 Differential Revision: https://phabricator.services.mozilla.com/D35374 UltraBlame original commit: d5f3bcfcd6bdf0245264e94e5050aa3dde799938
…g `./mach browsertime` r=nalexander If `./mach browsertime` runs browsertime with a globally-installed node, due to an existing bug in [execa][1], the wrong Python will be executed. We now specify the full path of the Python binary we wish to use (via the `PYTHON` environment variable that our fork of browsertime supports) and avoid this issue altogether. [1]: sindresorhus/execa#153 Differential Revision: https://phabricator.services.mozilla.com/D35374 UltraBlame original commit: d5f3bcfcd6bdf0245264e94e5050aa3dde799938
…g `./mach browsertime` r=nalexander If `./mach browsertime` runs browsertime with a globally-installed node, due to an existing bug in [execa][1], the wrong Python will be executed. We now specify the full path of the Python binary we wish to use (via the `PYTHON` environment variable that our fork of browsertime supports) and avoid this issue altogether. [1]: sindresorhus/execa#153 Differential Revision: https://phabricator.services.mozilla.com/D35374 UltraBlame original commit: d5f3bcfcd6bdf0245264e94e5050aa3dde799938
I have two installations of git and
execa
seems to pick the wrong one, not respecting$PATH
correctly, whilechild-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):I am missing something here?
The text was updated successfully, but these errors were encountered: