1

I set my Visual Studio Code user settings to: terminal.integrated.shell.windows": "C:\Program Files\Git\bin\bash.exe"

But when I open the integrated terminal, I get the following error and no git commands will work:

412 [main] bash 4352 fork: child -1 - CreateProcessW failed for 'C:\Program Files\Git\bin..\usr\bin\bash.exe', errno 13 bash: fork: Permission denied

Any idea why this error occurs? I tried uninstalling and reinstalling git but that didn't help. I also restarted Visual Studio Code, to no avail. Screen-shot of VS settings and integrated terminal.

R4F6
  • 782
  • 1
  • 9
  • 26
Adrian N
  • 11
  • 4

2 Answers2

0

Try running vscode as an administrator. Program Files is a (somewhat) protected location in Windows, and if vscode is not run as an admin, it wont be able to access your git executable.

R4F6
  • 782
  • 1
  • 9
  • 26
  • Thanks, I tried running vscode as admin but got the same error, however you are probably on the right track; the machine I am using belongs to the company I work for. – Adrian N Nov 24 '17 at 20:35
  • Are you sure that is the right location for your git executable? I know Windows will throw that error when the executable youre trying to run doesnt exist. `Program Files(x86)` maybe? – R4F6 Nov 25 '17 at 22:04
  • Thanks, I tried uninstalling and then re-installing to Program Files(x86) but there it would not open at all. In the Program files location it will open but it makes several tries before it is successful. This occurs even when opening as an administrator. – Adrian N Dec 03 '17 at 20:37
0

I was experiencing almost this exact same problem with Visual Studio. To make it even more confusing, VS Code worked, and Visual Studio had worked prior to adding a pre-commit hook (but that could have just been coincidental timing.)

Eventually I stumbled upon this answer Git Bash Error: Could not fork child process: Permission denied (-1). While the details in that question are slightly different, the cause was the same for me: company antivirus was blocking sh.exe.

We had already added an exclusion, but for Git for Windows. Visual Studio has their own installation, with its own location and a different SHA for sh.exe, and that also needed to be added as an exception.

Once that propagated, I was able to run the script... up to the next error, which may or may not be related.

John Neuhaus
  • 1,784
  • 20
  • 32