Failed to launch git bash - bash

The terminal process command 'C:\Program Files\Git\bin\bash.exe' failed to launch (exit code: 2)
I have already setup git. Git directory:

I had this issue with the 'start git-bash' extention in vscode. You just need to add the folder "C:\Program Files\Git\" to your path and restart vs code.

I reinstalled Git and all work well
Working Git Bash

If you have this issue, with the following error code:
'ExecutionPolicy', 'Bypass'" terminated with exit code: 2.'
What worked for me is I went into the settings.json file and removed the following line:
"terminal.integrated.shellArgs.windows": ["-ExecutionPolicy","Bypass"]

If Git Bash doesn't work you can try installing a Windows WSL2 such as Ubuntu 18.04 and use that instead of Git Bash.
Here is how you select a Windows WSL:
Check out this link if you need help installing WSL2 on Windows.

You can see a similar issue (with cmd, not bash) in Microsoft/vscode issue 62953.
Try with a portable version of Git bash (like PortableGit-2.20.0.rc1.windows.1-64-bit.7z.exe), uncompress in a custom folder (like C:\Git, instead of C:\Program Files\Git)

Sometimes antivirus software might cause that behaviour, since launchin a terminal involes a process creating another process.
So add an exception in your Antivirus for Visual Studio Code or stop all the antivirus related services --at your own risk--

First, check that you have Git Bash downloaded on your PC. If you already have it installed, then check you can access python program.
If not installed, please install directly from the following link: https://git-scm.com/download/win

Related

command not found after reinstalling git bash with "Windows default console window"

Before re-installing Git Bash, I was using "MinTTY as default terminal emulator". I just wanted my git bash to be colorful! Reinstall, follow this stackoverflow answer. Then when I use the same Git Bash apparently my common commands which is already installed before like:
nvm
node
npm
code
Is all gone! How do I get all of my command list back? I have python running thought, because I wrote in .bashrc alias python= winpty python. Are there any way to add those commands without adding them one by one through PATH environment variables? Or do I have to keep adding my list in .bashrc?
Thank you!
thank you for the attention.
Apparently, I was using the first CLI that is offered by the installation launcher after the installation is done. With the same CLI, I was so confused why does this CLI doesn't run my usual commands. However, turns out it can be solved by simply closing and opening a new CLI. Then everything went fine.
I sure felt so silly. Should've tried restarting it from the beginning.

GIT Issue on Windows (The filename or extension is too long)

Overview:
Just installed the GIT version 2.20.1-64-bit on my Windows 7 platform. Git works well on GIT Bash; but, any git command on Windows CMD or Powershell raises The filename or extension is too long error.
Details:
GIT version: 2.20.1-64-bit
Platform: Windows 7
Troubleshooting Efforts:
I tried switching longpaths attribute to true based on Filename too long in Git for Windows. I also googled to find other solutions but all recommended the same approach which was updating the git config.
The GIT config file updated with git config --system core.longpaths true
Issue:
Any Git command via Windows CMD or 3rd party apps like IntelliJ Idea raises the following error:
CMD:
IntelliJ:
Please advise me with your genuine solutions.
I had the same problem. I then installed it in my user folder and now it works. It seems to be a privilege issue. Git gets installed as admin in C:\Program Files\Git but then can't write to these files because it is run as a user.
Also using the portable version should fix the problem.
Try first to use a simplified PATH and a portable Git (like PortableGit-2.20.1-64-bit.7z.exe) uncompressed anywhere you want.
set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%PATH%
Then check if the issue persists in that CMD session, where you have set said simplified PATH.

Git Bash -Segmentation Fault Problem (Windows)

Indeed I have same issue which is mentioned here "Why does bash (from git installation) give me segmentation fault suddenly?
"
My git was working properly. But I need to regenerate keygen value and I got segmentation fault. I remoted git and installed the latest version of git (2.19.0-64-bit). I tried with git-bash from search, bash.exe from bin folder , git.exe from bin folder , git-bash.exe under Git Folder and git-cmd.exe under Git folder. The results are same.
After I read the link I shared above , I checked the windows updates as well. But there is no update.
Is there any idea ? Thanks in advance
2.9 is not the latest, one: 2.19 is.
Try (for testing) and uncompress the latest Git for Windows portable archive PortableGit-2.19.0-64-bit.7z.exe anywhere you want.
Then setup a simplified path in a CMD session.
set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem
set GIT_HOME=C:\Path\to\Git
set PATH=%GIT_HOME%;%GIT_HOME%\bin;%GIT_HOME%\usr\bin;%GIT_HOME%\mingw64\bin;%PATH%
(Add any other path you would need)
Try then to regenerate your SSH key.
Also, make sure this is not related to an AV (Anti-Virus) as in issue 1832 or issue 1291.
My company also uses TrendMicro.
Can confirm that making an exception for /Git/usr/bin/bash.exe works as well.
For me it was C:\Program Files\Git\usr\bin, but adding it to the list of trusted programs did indeed fix the issue
I faced the same problem yesterday. Using git-bash, all my commands (i.e. mvn, javac, git pull) were giving error "Segmentation fault". This was because an update of my machine anti-virus which blocks proper access to my local login profile (sambit-swain#TERMINAL) After un-installing it, everything went back to normal.
So, the problem is not with GIT BASH or any other configuration. I should have checked the access levels (including SSH keys) to programs.

How can I run PHPUnit from git bash on Windows?

I have Windows 7, phpunit is installed via these instructions: https://phpunit.de/manual/current/en/installation.html and works fine from regular cmd terminal, but phpunit is not recognized in the windows git bash terminal installed from git-scm.
I'm mainly a linux developer, so setting this stuff up on Windows is a little foreign to me.
Use alias native will be much better. edit ~/.bashrc, add these in it:
alias phpunit="php /C/Tools/php/phpunit.phar" // phpunit.phar in C:\Tools\php\phpunit.phar
copy the phpunit.phar file and rename the dumplicate file to phpunit
rename C:\bin\phpunit.phar to C:\bin\phpunit
Fix: PHPUnit not working with Git Bash in Windows
Just run into the same problem myself, see this answer provided at SuperUser https://superuser.com/a/663187, basically the problem is that Git Bash does not run ".bat" files:

cmd 'patch' is not recognised as an internal/external command, operable program or batch file

I'm trying to patch my wordpress installation to protect from user enumeration.
I found a patch - here
It said to use it I need to navigate to the sites root folder, add the patch file then run it using cmd , patch -p0 <wpuserEnum.patch
When I hit enter I get the 'patch' is not recognised as an internal/external command, operable program or batch file' message
Not the most helpful error reporting. I have googled the problem all day and have not found any solutions regarding 'patch' specifically
I have checked PATH and there is a C:\Windows\System32 path there
Can anybody shed any light on what is happening and why?
I am running Windows Server 2008.
patch is not part of Windows so it won't be installed unless you install it yourself. You can get it as part of the GnuWin32 project - http://gnuwin32.sourceforge.net/packages/patch.htm
You need to edit your system environment variables, then add the path to patch.exe(in GnuWin32\bin) to the PATH environment variable...after restarting the cmd, patch should be recognized...
It helped me to run the next command:
npm i patch-package
(From here: https://www.npmjs.com/package/patch-package )
I don't think GnuWin32 works for Win10 (at least they only mentioned Win7 in their website).
The safest way (works for me) is Git for Windows: https://git-scm.com/download/win
It has patch.exe in Git\usr\bin folder. Just add it to your path will work!

Resources