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

Remote Container with WSL 2 support activated: Git credentials not available #2858

Closed
J0F3 opened this issue Apr 28, 2020 · 21 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers verified Verification succeeded
Milestone

Comments

@J0F3
Copy link

J0F3 commented Apr 28, 2020

  • 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

@J0F3 J0F3 changed the title Remote Container with WSL2: Git credentials not available Remote Container with WSL 2 support activated: Git credentials not available Apr 28, 2020
@PavelSosin-320
Copy link

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

@cailloumajor
Copy link

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.

@chrmarti
Copy link
Contributor

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

@chrmarti chrmarti added containers Issue in vscode-remote containers info-needed Issue requires more information from poster labels Apr 29, 2020
@cailloumajor
Copy link

@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 microsoft/vscode-pull-request-github#1221, but pushing went well after that.

@J0F3
Copy link
Author

J0F3 commented Apr 29, 2020

@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.

@chrmarti
Copy link
Contributor

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

@J0F3
Copy link
Author

J0F3 commented Apr 30, 2020

@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?

@chrmarti
Copy link
Contributor

@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.

@J0F3
Copy link
Author

J0F3 commented Apr 30, 2020

@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?

@chrmarti
Copy link
Contributor

@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 chrmarti added this to the April 2020 milestone Apr 30, 2020
@J0F3
Copy link
Author

J0F3 commented Apr 30, 2020

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

@chrmarti
Copy link
Contributor

@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).

@PavelSosin-320
Copy link

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

@PavelSosin-320
Copy link

Git documentation says that Git expects a lot: GitEnvVariables

@J0F3
Copy link
Author

J0F3 commented Apr 30, 2020

@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.

@J0F3
Copy link
Author

J0F3 commented May 4, 2020

@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? 🤓😉

@chrmarti
Copy link
Contributor

chrmarti commented May 4, 2020

@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.

@J0F3
Copy link
Author

J0F3 commented May 4, 2020

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

@chrmarti
Copy link
Contributor

chrmarti commented May 4, 2020

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

@J0F3
Copy link
Author

J0F3 commented May 4, 2020

@chrmarti Awesome, it works! So I would say it is fixed! 😁👍 Thanks a lot!

@chrmarti
Copy link
Contributor

chrmarti commented May 4, 2020

Great, thanks @J0F3 !

@chrmarti chrmarti added bug Issue identified by VS Code Team member as probable bug verified Verification succeeded labels May 4, 2020
@chrmarti chrmarti removed the info-needed Issue requires more information from poster label May 4, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Jun 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug containers Issue in vscode-remote containers verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants