Repository navigation
Description
- VSCode Version: 1.2.1
- OS Version: Windows 10 Build 14367
Steps to Reproduce:
- Install Cygwin
- Edit .vscode/settings.json to set
git.pathto point to"\\cygwin64\\bin\\git.exe - VS Code throws up an error message of
ENOENT: no such file or directory, lstat 'C:\cygdrive', as described here
This is, of course, because Cygwin namespaces the filesystem differently. However, doing this (which usually fixes things in other tools):
"git.path": "\\cygwin64\\bin\\bash.exe git",
...then results in further confusion as Code apparently does not have a way to correctly set the environment for the git process, which then defaults to the wrong PATH:
git fetch
git show HEAD:.vscode/settings.json
git show HEAD:.vscode/settings.json
Could not create directory '/c/cygwin64/home/USERNAME/.ssh'.
ssh_askpass: exec(/usr/local/bin/win-ssh-askpass.exe): No such file or directory
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
git fetch
Could not create directory '/c/cygwin64/home/USERNAME/.ssh'.
ssh_askpass: exec(/usr/local/bin/win-ssh-askpass.exe): No such file or directory
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Trying to set PATH, HOME, etc. inline in the bash command line above fails for some reason I cannot yet fathom, but I would suggest a configuration setting git.env be created so that the environment external Git tools can be pre-configured (this would also benefit the Linux and OSX ports).
As to why this is necessary and why I can't use other Git binaries on Windows, the reason is simple:
Cygwin does Git over SSH "right", with completely identical setup in terms of SSH keys, options, CR/LF encoding, etc. Current Git for Windows simply does not work for my use case (I've tried), and, obviously, the Linux Subsystem doesn't help with this either.
Activity
joaomoreno commentedon Jun 22, 2016
Duplicate of #7361. We don't support cygwin git, sorry.
We've been using Git for Windows successfully in the team, complete with SSH keys, options, line ending encodings et al. What is the actual issue you get with it?
rcarmo commentedon Jun 22, 2016
Hmmm. So this is a dupe of a ticket that's closed because we've "just never really looked into it"?
My issue is that I can use exactly the same setup with Cygwin than on Linux without having to sort out the (rather clunky) Git for Windows options and separate management of SSH keys. It's just less friction for someone who has to work routinely on both environments. Personally, I would very much like not to have to use Git for Windows at all and just rely on the Cygwin binaries.
Also, you missed my suggestion of adding a
git.envsetting to set the environment for Git binaries, which is also useful on other platforms. Should I file an issue for that separately?joaomoreno commentedon Jun 22, 2016
If #7361 were open we would close this one the same way. It is a duplicate, in any case.
Apologies for coming out harsh.
Let me expand a bit on just never really looked into it. Code already needs to support whichever version of git you have installed in whichever platform you are using it. It is a non-trivial task that gets another complexity fold as soon as we add git flavours. We've found that Git for Windows handles the great majority of the tasks users need and I've personally have yet to find a reason that would make me use cygwin instead.
Of course, I can be wrong and I'm definitely interested in someone proving me wrong. That's why I asked about the actual issue you face. If it is really something Git for Windows does not support, of course we'll reconsider our position towards cygwin, and we'll work towards that.
rcarmo commentedon Jun 22, 2016
It's all about integration. When you use Cygwin and its userland (bash, CLI tools, SSH, etc.), you don't need an extra terminal emulator like PuTTY, you can use standard Git plugins that rely on Perl/Python etc. seamlessly, and you don't need to set up a copy of your SSH keys anyplace else.
Right now, the current (stunted and incomplete) UNIX userland clone that ships with Git for Windows doesn't provide me those affordances. Also, I can't set GIT_AUTHOR_* and GIT_COMMITTER_* on a per-repo basis using Git for Windows - it's just a surreal amount of pain to deal with that kind of thing inside it, when it all works perfectly in Cygwin.
With an environment setting I might not only actually get Cygwin Git to work (I suspect it's just a matter of setting the right HOME and a few more variables) but also have GIT_* settings set on a per-project basis for me inside VS Code. And this last bit will benefit every other platform, too.
joaomoreno commentedon Jun 22, 2016
Alright, let's keep this open for tracking the support. A PR would be much appreciated as we'll likely not have cycles to look into it any time soon.
Maybe next time I'm in the Lisbon office, I'll ping you and we'll get it working in an afternoon. 😉
[-]Cannot use Cygwin git binary[/-][+]Support cygwin git[/+]43 remaining items
AnrDaemon commentedon Apr 16, 2022
You can have multiple Cygwin environments installed on the same PC. And none of them in the $PATH.
I've long since abandoned the hope and installed Git-for-Windows (and told VS Code to use specifically that one).
ViPod5 commentedon Apr 16, 2022
maksim-pinguin commentedon May 4, 2022
as noted in #148720 i believe supporting the configured integrated terminal is the way to go. extensions like gitlense do this e.g.
AnrDaemon commentedon May 5, 2022
This is not enough.
Cygwin paths are inherently different from Windows paths, and VS Code do not understand that distinction.
ohhmm commentedon Jan 13, 2024
Vscode could have Git auto-detection for Windows from different sources:
It may be hardcoded preference or highest version preferred.
AnrDaemon commentedon Jan 14, 2024
Yet again - this is not about git.exe location, it is about Cygwin paths support.
ohhmm commentedon Jan 15, 2024
Yes, I got it AnrDaemon
Could you try to run Cygwin's git from cmd by its Windows path, please?
AnrDaemon commentedon Jan 16, 2024
Yes, you could. That's not the problem.
The problem starts when Cygwin Git return Cygwin paths which VS Code don't know how to interpret.
Or when VS Code provide Windows paths that means nothing to Cygwin Git.
It requires some extra care inside VS Code itself, and even then not fully fool proof, as other extensions may run Git directly by themselves.
DanKaplanSES commentedon Jan 16, 2024
AnrDaemon Yep. it's not just the difference in slashes, absolute paths and cygwin start with
/cygdrive/<drive letter>and in Windows, start with<drive letter>:\\. The last paragraph in your comment is especially tricky.Here's my workaround, and I didn't come up with it on my own. In fact, I may be summarizing something already in this thread.
I added this line to
settings.json:"git.path": "C:\\cygwin64\\home\\<user>\\vscode_git_compatibility\\cygpath-git-vscode.bat",.$ cat cygpath-git-vscode.bat:I don't know why, and I don't know if it's actually used (running
ag -l 'cygpath-git-editor.sh'in my home directory finds nothing), but I have another file inC:\\cygwin64\\home\\<user>\\vscode_git_compatibility\\namedcygpath-git-editor.sh.$ cat cygpath-git-editor.sh:I'm kind of in a rush so I don't have the time to verify if these are the only steps, but it is what I currently use. I hope this can be of help to someone. I want to reiterate that AnrDaemon 's last paragraph still applies.
AnrDaemon commentedon Jan 17, 2024
The workaround is to install Git-For-Windows in a separate directory and point VS Code to it.
DanKaplanSES commentedon Jan 17, 2024
Are providing an alternative workaround or explaining mine?
AnrDaemon commentedon Jan 17, 2024
Restating the obvious.
DanKaplanSES commentedon Jan 18, 2024
Not obvious enough, it seems. It looks like you said this back in 2022, but I hadn't noticed until now. The next reply provides a different workaround that may have buried yours.
If you use the git-for-windows work around, can you still use cygwin's
gitin the same project, or do they step on each other's toes? I use the git command line 95% of the time; I only need VS Code to understand enough to mark my files as modified.AnrDaemon commentedon Jan 18, 2024
I do.
Cygwin is my go-to *NIX tools, I only install native ports/equivalent tools when one of the following statements is true:
edemaine commentedon Aug 27, 2026
For what it's worth, I tried to make a more robust shim solution, inspired by cyg-git which I first learned about on this thread.
Cygshim should be easier to install (single prebuilt binary, then update PATH) and should handle edge cases better. In addition to Git, it provides LaTeX shims for LaTeX Workshop. If you have ideas for further improvements or extensions (e.g. other commands that need shims), let me know (on cygshim repo not here).