Reputation: 2158
I have looked at most of the posts describing the first error on the title : "Visual Studio Code cannot detect installed git".
Nevertheless, I believe that the second error "error launching git: The filename or extension is too long." generates the first one.
Could you help me?
Any idea?
Thank you for the time invested!
Upvotes: 4
Views: 19945
Reputation: 2894
On Mac, it was working fine and suddenly it wasn't anymore.
I noticed it was caused by Xcode updating the git and the user agreement. I had to re-accept it if I wanted to use git from CLI.
So, running sudo xcodebuild -license
and accepting the license solved the issue.
Upvotes: 2
Reputation: 865
For MAC, you should rather add below to settings.json
file
"git.path": "/usr/local/git/bin/git"
For windows, you should add
"git.path": "C:\\Program Files\\Git\\mingw64\\bin\\git.exe"
Upvotes: 0
Reputation: 2158
I have executed the command where git
on Windows Command prompt :
C:\Users\<my-user>where git
c:\Program Files\Git\bin\git.exe
C:\Program Files\Git\cmd\git.exe
I have executed the command where git
on GIT BASH :
$ where git
C:\Program Files\Git\mingw64\bin\git.exe
C:\Program Files\Git\bin\git.exe
C:\Program Files\Git\cmd\git.exe
I have executed the command git --version
on C:\Program Files\Git\bin\git.exe
:
$ "C:\Program Files\Git\bin\git.exe" --version
error launching git: The filename or extension is too long.
I have executed the command git --version
on Git\mingw64\bin\git.exe
:
$ "C:\Program Files\Git\mingw64\bin\git.exe" --version
git version 2.20.1.windows.1
Git Bash has a third version of git installed which works on my computer in this path C:\Program Files\Git\mingw64\bin\git.exe
Visual Studio Code > File > Preferences > Settings > Search Settings - type git.path > Edit in settings.json
{
"git.path": "C:\\Program Files\\Git\\mingw64\\bin\\git.exe",
...
}
Now, Git works again on Visual Studio Code
Upvotes: 9
Reputation:
Your .vscode/settings.json contains "git.path": "c:\Program Files\Git\bin\git.exe" with duplicated backslashes (on image c:\\Program Files\\Git\\bin\\git.exe
).
If you go in VSCode terminal with cd command to c:\Program Files\Git\bin\ and run git.exe have the same error?
Upvotes: 0