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

"credential-cache unavailable; no unix socket support" #3892

Closed
hickford opened this issue Jun 13, 2022 · 12 comments
Closed

"credential-cache unavailable; no unix socket support" #3892

hickford opened this issue Jun 13, 2022 · 12 comments

Comments

@hickford
Copy link

hickford commented Jun 13, 2022

I tried to run git-credential-cache but got an error:

> git credential-cache
fatal: credential-cache unavailable; no unix socket support

Others have reported the same error https://stackoverflow.com/questions/67951554/error-fatal-credential-cache-unavailable-no-unix-socket-support

A workaround is to install and configure Git Credential Manager git-credential-manager-core --configure. The default credential store Windows Credential Manager works well.


Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options
git version 2.36.1.windows.1
cpu: x86_64
built from commit: e2ff68a2d1426758c78d023f863bfa1e03cbc768
sizeof-long: 4
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver
Microsoft Windows [Version 10.0.19043.1682]
@dscho
Copy link
Member

dscho commented Jun 14, 2022

fatal: credential-cache unavailable; no unix socket support

Well, it is true. Windows does not have Unix socket support in general. As per this comment:

echnically, since Git v2.34.0, git-credential-cache.exe can be built and run on Windows. Unix Sockets support has been introduce into Windows. The problem is that you need Windows 10 build 17061 or later, and Git for Windows still supports even Vista (although it has been announced that Git for Windows will drop supporting Vista really soon now).

Now, the question is: how much are you interested in getting Git for Windows to support credential-cache on Windows versions that support Unix sockets @hickford? Interested enough to work on a PullRequest? If so, I will be glad to assist, but I won't be able to justify the time to work on it myself.

@hickford
Copy link
Author

hickford commented Dec 2, 2022

How might that work? I don't have much C experience. Is it possible to change an optional compile-time dependency to a conditional runtime dependency? Or would Git for Windows have to compile credential-cache with and without sockets, and install the appropriate copy for the system?

@rimrul
Copy link
Member

rimrul commented Dec 2, 2022

It is possible to query for unix socket support at runtime and we have ways to load CRT functions at runtime if available, so that approach is theoretically feasible.

@hickford
Copy link
Author

hickford commented Dec 3, 2022

ways to load CRT functions at runtime if available

@rimrul Do you have any examples to follow?

The good news is that credential-cache is confirmed to function on Windows if compiled (thanks @carenas).

@rimrul
Copy link
Member

rimrul commented Dec 5, 2022

Yes, of course. Sorry for not providing you with more actionable info on this.

We have the macros DECLARE_PROC_ADDR() and INIT_PROC_ADDR() defined in compat/win32/lazyload.h.

You can see them in use in t/helper/test-drop-caches.c, compat/winansi.c, compat/win32/trace2_win32_process_info.c and two times in compat/mingw.c.

@hickford
Copy link
Author

hickford commented Dec 28, 2022

@rimrul interesting. This seems slightly different. If I understand correctly, the winsock2.h socket function in Ws2_32.dll is available on all versions of Windows. What's missing in older versions is header afunix.h with struct sockaddr_un.

What happens at runtime if you build with sockets on Windows 10 then try to run on Windows 7?

According to the docs above, the socket function should return error INVALID_SOCKET (specific error code WSAGetLastError). But will the application even start?

@dscho
Copy link
Member

dscho commented Jan 19, 2023

What happens at runtime if you build with sockets on Windows 10 then try to run on Windows 7?

@hickford It won't work. Likewise if you run on older Windows 10 that lack support for AF_UNIX. Something we need to test specifically, to ensure that the users will see a helpful error message (and not, say, a crash).

ldennington pushed a commit to ldennington/git-credential-manager that referenced this issue Jan 23, 2023
GCM's documentation states that git's credential cache is supported on
Windows. Unfortunately, due to lack of Unix socket support on Windows
versions prior to Windows 10, this feature is not currently supported on
Windows, so this change removes it from the list of platforms on which
this credstore can be used. See [1] for more details.

[1]: git-for-windows/git#3892
ldennington added a commit to git-ecosystem/git-credential-manager that referenced this issue Jan 23, 2023
GCM's documentation states that git's credential cache is supported on
Windows. Unfortunately, due to lack of Unix socket support on Windows
versions prior to Windows 10, this feature is not currently supported on
Windows, so this change removes it from the list of platforms on which
this credstore can be used. See [this
issue](git-for-windows/git#3892) for more
details.
@rimrul
Copy link
Member

rimrul commented Jan 10, 2024

What happens at runtime if you build with sockets on Windows 10 then try to run on Windows 7?

@hickford It won't work. Likewise if you run on older Windows 10 that lack support for AF_UNIX. Something we need to test specifically, to ensure that the users will see a helpful error message (and not, say, a crash).

I did some testing. Running Git for Windows 2.43.0 built without NO_UNIX_SOCKETS on Windows 8.1 we don't get a crash. Directly calling git credential-cache produces the usage message as it would on systems with unix sockets. Actually using the credential helper as a credential helper in git clone produces this not great error message:

fatal: unable to connect to cache daemon: Unknown error

I think we could improve that error message with a runtime check.

  • The simplest check would be to see if GetVersion() reports that we're on Windows 10 build 17063 or newer. That should work for most cases, but might not work in certain edge cases.
  • Microsoft recommends checking sc query afunix, but I'd rather not shell out to a new process if we don't have to. We could probably achieve the same result using OpenServiceA()/OpenServiceW() and QueryServicestatus()/QueryServiceStatusEx(),
  • We could also just try wether we can successfully create a unix socket at startup.

@hickford
Copy link
Author

hickford commented Feb 4, 2024

@rimrul Exciting ideas!

Git for Windows 2.43.0 built without NO_UNIX_SOCKETS

Please could you share git-credential-cache.exe and git-credential-cache--daemon.exe here?

@rimrul
Copy link
Member

rimrul commented Feb 5, 2024

Git for Windows 2.43.0 built without NO_UNIX_SOCKETS

Please could you share git-credential-cache.exe and git-credential-cache--daemon.exe here?

I could do that, but do you really want my locally built binaries that are just without NO_UNIX_SOCKETS? Wouldn't it make more sense to extract the binaries with the dynamic detection from the windows-artifacts CI build artifact at https://github.com/git-for-windows/git/actions/runs/7491375798?

@hickford
Copy link
Author

hickford commented Feb 13, 2024

@rimrul I can't find the credential-cache binaries in windows-artifacts.zip.

rimrul added a commit to rimrul/git that referenced this issue Apr 3, 2024
Windows 10 build 17063 introduced support for unix sockets to Windows.
bb390b1 (git-compat-util: include declaration for unix sockets in
windows, 2021-09-14) introduced a way to build git with unix socket
support on Windows, but you still had to decide at build time which
Windows version the compiled executable was supposed to run on.

We can detect at runtime wether the operating system supports unix
sockets and act accordingly for all supported Windows versions.

This fixes git-for-windows#3892

Signed-off-by: Matthias Aßhauer <[email protected]>
Nekosha pushed a commit to Nekosha/git-po that referenced this issue Apr 16, 2024
Windows 10 build 17063 introduced support for unix sockets to Windows.
bb390b1 (git-compat-util: include declaration for unix sockets in
windows, 2021-09-14) introduced a way to build git with unix socket
support on Windows, but you still had to decide at build time which
Windows version the compiled executable was supposed to run on.

We can detect at runtime wether the operating system supports unix
sockets and act accordingly for all supported Windows versions.

This fixes git-for-windows#3892

Signed-off-by: Matthias Aßhauer <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
@ogauge

This comment was marked as spam.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants
@hickford @dscho @rimrul @ogauge and others