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

Support for Git-bash on Windows. #238

Closed
wants to merge 1 commit into from
Closed

Support for Git-bash on Windows. #238

wants to merge 1 commit into from

Conversation

jwmcgettigan
Copy link

This is the only method I could think of for detecting if a user is in a bash environment on a Windows machine - and thus the best solution I could think of to issue #226 .

I've made it so that if the user is on a Windows machine, it will check whether they are running nodeenv from a bash.exe terminal (such as git-bash). This is being done using psutil to check the name of all parent processes and run/install/treat as CYGWIN instead of as Windows if a bash.exe process is detected among these parent processes.

Please let me know what you think of this solution.

@ceremcem ceremcem mentioned this pull request Aug 6, 2020
@s-weigand
Copy link

s-weigand commented Jun 26, 2022

I guess detecting if a sh.exe or bash.exe is on the PATH can be done using shutil.which and doing a is None check.

In [1]: import shutil

In [2]: shutil.which("sh.exe")
Out[2]: 'C:\\Program Files\\Git\\bin\\sh.exe'

In [3]: shutil.which("bash.exe")
Out[3]: 'C:\\Program Files\\Git\\bin\\bash.exe'

In [4]: shutil.which("not_on_path.exe")

In [5]: type(shutil.which("not_on_path.exe"))
Out[5]: NoneType

At least for me the platform.system() added in #263 does not work in git-bash 😥

In [6]: import platform

In [7]: platform.system()
Out[7]: 'Windows'

In [8]: is_CYGWIN = platform.system().startswith(('CYGWIN', 'MSYS'))

In [9]: is_CYGWIN
Out[9]: False

The added bonus of this method would be that even if you create the end in a different console (cmd or powershell) you would still get your activate file that you can source from git-bash (and ofc no extra dependency on psutil).

@ekalinin
Copy link
Owner

Looks like outdated. Thank anyway!
Please, reopen the issue, if you would like to continue.

@ekalinin ekalinin closed this May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants