Vscode-remote-release: Remote Container with WSL 2 support activated: Git credentials not available

Created on 28 Apr 2020  路  21Comments  路  Source: microsoft/vscode-remote-release


  • VSCode Version: 1.44.2 ("remote.containers.experimentalWSL" setting set to "true") / 1.45.0-insider
  • Local OS Version: Windows 10, 2004 Build: 19041.207 (Insider Slow Ring)
  • Remote OS Version: Ubuntu 18.04 (WSL 2)
  • Remote Extension/Connection Type: Dev Container

Steps to Reproduce:

  1. Open Folder via \wsl$\Ubuntu...
  2. Remote Container: Reopen in Container
  3. Container start successfully, Folder and Git configuration available in container
  4. Run a Git operation against private Git Repo (e.g. git pull)
  5. Get asked for Username and Password. So the Git Credential Helper configured in WSL seems not be used.

So it is basically what is described in the last section ("Check that Git credentials are forwarded from the WSL distro:") in #2849 which does not work for me with the activated experimental WSL support of the Remote - Container extension.

I tested the same also using SSH and SSH Agent configured in WSL. But the result/problem is the same.

Interesting is that when the container is started once with "remote.containers.experimentalWSL" set to "ture" and then the setting is changed to "false" the container can reopened again and then git pull works as expected. (Git credential manager gets used and no questions about username and password).

Git config in WSL 2 / Ubuntu:

git config -l
[email protected]
user.name=Jonas Feller
credential.helper=/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe
core.editor=code --wait
fetch.prune=true

Git config in Remote Container:

git config -l
[email protected]
user.name=Jonas Feller
credential.helper=!f() { /home/cin/.vscode-server-insiders/bin/abb4a35cfc26102f93fd00df7b59ce1a19c2017a/node /tmp/vscode-remote-containers-7ae52994d3c2bcde34bf856edbff7efc8422a2e2.js $*; }; f
core.editor=code --wait
fetch.prune=true


Does this issue occur when you try this locally?: No
Does this issue occur when you try this locally and all extensions are disabled?: No

As the feature is described as experimental I am not sure if this is actually a bug or if it is a known issue/restriction. But I thought I would be worth to post it here to clear things up. 馃槈

Thanks!
Jonas

bug containers verified

All 21 comments

Honestly, I solved almost all cross VM / Host configuration issues using big hammer method:
I created in WSL distro symbolic links for all dotfiles and config files that I use like .git, .docker, .kube .etc . It's impossible to create cross fs hard link but it's\OK for the symbolic link and Linux CLI's don't check the link type. I suppose it will work in many cases with proper volume mapping z

I encounter the same problem, in the same conditions except that I am on a public Github repo.
Feel free to ask if someone wants me to test something.

@J0F3 Could you retry with current VS Code Insiders (https://code.visualstudio.com/insiders/) and Remote-Containers 0.113.0?

@chrmarti Works for me with VS Code Insiders and Remote-Containers 0.113.0.
I had to use Chrome instead of Firefox to authorize with GitHub, due to https://github.com/microsoft/vscode-pull-request-github/issues/1221, but pushing went well after that.

@chrmarti Unfortunately still the same for me with VS Code Insiders (just updated today) and Remote-Containers 0.113.0.
But I see now in the Dev Containers log the following error as soon as I run git pull

Remote-Containers server: {
  message: "Cannot read property 'code' of undefined",
  name: 'TypeError',
  stack: "TypeError: Cannot read property 'code' of undefined\n\tat " +
    'c:\\Users\\jfeller\\.vscode-insiders\\extensions\\ms-vscode-remote.remote-containers-0.113.0\\dist\\extension.js:1:132170'
}

And on the terminal I have the following error:

<3>init: (5393) ERROR: UtilConnectToInteropServer:300: connect failed 2

I have tried with a Repo on GitHub and on GitLab.

@J0F3 Is there anything in the dev console? (Help > Toggle Developer Tools)

@chrmarti Not really more than what is in the Dev Container Log: -1588228884901.log

It is really strange. Just noticed that with a GitHub Repo I have the same error messages but pushing and pulling from this repo works as expected (no credential prompts). But with a (private) GitLab Repo it does always show the credential prompts. (not in WSL 2 though).

Does it maybe matter when I have also the stable version of VS Code installed in parallel?

Because on anther computer both works. But there I have only the VS Code insiders and a slightly newer Windows Build installed (because it is on the Insider Fast Ring).

@cailloumajor What Windows Build do you have installed?

@J0F3 I think VS Code Insiders adds GitHub auth support, so when the Git credentials cannot be fetched from the Windows / WSL side, it will ask you to sign in via GitHub.

Can you run git fetch in the WSL2 distro without being asked for credentials? We use git in WSL2, not in Windows, to look up credentials when connected via WSL2.

@chrmarti Ah yes, this would example the difference between the GitHub and GitLab Repo.

Yes, git fetch works in the WSL2 distro with out being asked for the credentials. But I have configured Git in WSL 2 to use the Windows Git Credential Manager (credential.helper=/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe) which extremely handy. But maybe that is the problem?

@J0F3 I would expect that to work. I'm fixing the "Cannot read property 'code' of undefined" error which seems to hide the underlying issue.

@chrmarti Sounds, good. Just let me know if I should test anything further.

@J0F3 Could you retry with Remote-Containers 0.114.0 in VS Code Insiders? That should hopefully give a better error message (either in the containers log or the dev console).

Hi, @chrmarti Please check what is your environment in the remote container. When I run it manually it contains nothing related to git

Git documentation says that Git expects a lot: GitEnvVariables

@chrmarti Thx. I just tried again with Remote-Containers 0.114.0 in VS Code Insiders. But unfortunately no other error messages. The only error I get is <3>init: (11837) ERROR: UtilConnectToInteropServer:300: connect failed 2 in the terminal where I enter the git fetch and nothing in the dev tools.

In addition to that I have to correct my self. I mentioned above that it would work on my other laptop. But that was actually not true. (I accidentally tested with a repo cloned in Windows instead in the WSL distro). It does not work on both of my computers. But on the second computer I get a slightly different error message:
<3>init: (2259) ERROR: UtilConnectUnix:466: connect failed 111

Furthermore I tested now also with SSH Auth but that does not work either. Then the my SSH key is not found an ssh-add -l (inside the container) says Could not open a connection to your authentication agent. But inside the WSL 2 distro it works also using SSH. (ssh-agent is running on the WSL2 distro).
However this just as a side note...

Let me know if I can do anything more.

@chrmarti Why did you closed that now? Could you fix it?

I think the authentication with credentials / credential helper for repos cloned via HTTPS and authentication via SSH keys for repos cloned via SSH are two things. So the new issues for SSH makes perfectly sense for me. But this one here should also be stay open as the problem with the credential helper for HTTPS repos is still a problem which still should be fixed. Right? 馃馃槈

@J0F3 I have a fix queued for the upcoming 0.115.0 release. I have closed the issue for my own book-keeping, that is necessarily a little earlier than you can test the fix. Will let you know when the new version is out.

@chrmarti Ah cool! Good to hear that. Looking forward to test it. 馃槉 Thanks!

@J0F3 0.115.0 is out. Could you give that a try?

@chrmarti Awesome, it works! So I would say it is fixed! 馃榿馃憤 Thanks a lot!

Great, thanks @J0F3 !

Was this page helpful?
0 / 5 - 0 ratings