Skip to content
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

lerna does not respect $PATH variable #1758

Closed
lucasbraun opened this issue Nov 2, 2018 · 7 comments
Closed

lerna does not respect $PATH variable #1758

lucasbraun opened this issue Nov 2, 2018 · 7 comments

Comments

@lucasbraun
Copy link

lucasbraun commented Nov 2, 2018

I want to use a different git version than the one in /usr/bin because that one is too old for lerna publish) to work. I have added my newer git version (which works with lerna) to $PATH, but lerna seems to pick the one in /usr/bin nevertheless (even if I explicitly remove /usr/bin from $PATH). I was able to track the problem down to execa which seems to be the root cause of that problem and I created a ticket there (with more information how to reproduce my problem):
sindresorhus/execa#153

Could you please integrate their changes as soon as they become available? That would be much appreciated.

Thanks!

@ThisIsMissEm
Copy link
Contributor

This seems like an issue where we'd need to know what the expected behaviour of execa is in order to resolve.

@evocateur
Copy link
Member

This isn't a lerna issue. Once the issue is resolved with execa, unless it's a major version, there's nothing for lerna to do.

@westmark
Copy link

westmark commented Dec 19, 2018

We encountered this exact problem today. The issue is that execa defaults the option preferLocal to true, which means it will by default prepend some paths, including the path for the node executable(process.execPath). In our case it prepended with /usr/bin which contained an old version of git. This happened on a Jenkins server outside of our control and which was poorly maintained(apparently).

We don't expect execa to change this behaviour, so we propose that lerna default to sending preferLocal: false in all calls to sync(), or at least allow preferLocal to be configurable in lerna.json.

@evocateur
Copy link
Member

How exactly does execa's preferLocal option cause this error? npm-run-path is what is actually modifying the env when preferLocal is true, but I don't see how it would prepend paths like /usr/bin by itself.

@westmark
Copy link

Yes, npm-run-path modifies the env, and thereby the PATH when preferLocalis true. Since it is true by default, the user can never trust that whatever PATH they have constructed will be respected. And like I wrote, npm-run-path will prepend the PATH with, among other things, the path where the current node executable is located, which of course will vary from system to system. On a poorly maintained system where there may be old versions of git etc. lying around, this becomes a problem.

@evocateur
Copy link
Member

Looking deeper, I do indeed see the problem in npm-run-path. There is an open PR that needs some help. This option won't change in lerna because it is necessary to make hoisted executables work, as well as maintain parity with npm run semantics.

@lock
Copy link

lock bot commented Mar 31, 2019

This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Mar 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants