2

My VSCode is having a difficult time with Golang and its updates with GitHub. On console, I can use Git normally, I also use go commands to build and run my go applications and everything works just fine. But, when I use VSCode, it simply cannot manage to authenticate via SSH the same way the console does.

The complete message is:

Error loading workspace: err: exit status 1: stderr: go: github.com/abc/abc@v0.0.0-20210610172953-593247e413d4: 
invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in    
D:\Program Files\Go\bin\pkg\mod\cache\vcs\1c3dbe9a49296bf60aa851731c66574793ff0c41b2a50ff727de076b8a8fce2d: exit status 128: 
Permission denied (publickey). fatal: Could not read from remote repository. 
Please make sure you have the correct access rights and the repository exists. : packages.Load error

Anybody knows how to solve this?

Joe Almore
  • 4,036
  • 9
  • 52
  • 77
  • Correct answer is on this post: [VSCode, but show “Could not read from remote repository.”](https://stackoverflow.com/questions/34634364/to-use-git-push-on-visual-studio-code-but-show-could-not-read-from-remote-re/37882140) – Joe Almore Jun 13 '21 at 20:09
  • Which one? Launching VSCode in an environment where ssh-agent has been activated? (only needed if your private key is passphrase-protected) – VonC Jun 13 '21 at 20:16
  • @VonC Yes, that actually worked for me. – Joe Almore Jun 13 '21 at 20:58
  • OK. I have edited the answer accordingly. – VonC Jun 13 '21 at 21:43

1 Answers1

0

Check in a VSCode Terminal console (CMD) if you see any difference between:

  • ssh -Tv git@github.com (again, from the CMD in VSCode)
  • and ssh -Tv git@github.com from your regular CMD

There should be a difference in the path of the private keys considered for the connection, which should tell you why it does not work in VSCode (while it is working in your CMD)

A possible difference is, as pointed out by the OP with this answer, the presence in the VSCode parent process environment, of an ssh-agent.

If the private key is passphrase-protected, VSCode will need ssh-agent to read said key.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for your response. However, in both cases (in CMD in VSCode and on my regular CMD) I receive the same answer `You've successfully authenticated, but GitHub does not provide shell access.`. And the paths are the same also in both. Any other idea? – Joe Almore Jun 13 '21 at 19:45
  • @JoeAlmore Maybe https://stackoverflow.com/a/67580058/6309 – VonC Jun 13 '21 at 20:03