Marco
Marco

Reputation: 363

How do I make VS-Code find Git on Remote-SSH?

I am connecting from Windows to a Linux Server where I have no sudo-privileges. I installed git from an rpm package to my user folder and it's working:

enter image description here

I've tried adding the installation folder to $PATH on my ~/.profile, and it's there:

enter image description here

I've added git.path to my Remote settings.json:

enter image description here

I've also set the full permissions on /home/j348630/src and all subfolders and files. Finally I've tried to Reload the VS-Code Windows multiple times and even killed the remote .vscode-server in order to reset it.

Despite all this VS-Code still can't find my git installation:

enter image description here

enter image description here

What am I doing wrong?

Upvotes: 4

Views: 2367

Answers (1)

scadge
scadge

Reputation: 9743

Had this problem myself, also connecting from Windows to Linux. Spent a lot of time searching and tinkering, not sure if I found a general solution, but here's what helped me.

First the reasons: I suspect that I encountered this because initially that Linux machine did not have git in $PATH, i.e. git --version would tell that there's no such command. So, I added the proper path to git in my ~/.bashrc file. I see you did the same in .profile, perhaps try doing that in .bashrc as well just in case.

Alas, this by itself didn't help, even after multiple restarts and reconnects from the client side. So, I also decided to prepare a clean slate on the server side and removed everything under ~/.vscode-server/bin/ on the remote machine. If some files fail to remove, make sure you closed all the VS Code windows on the client side and perhaps even restart the client machine so that there's definitely no connection hanging on the remote files.

Now this finally worked after restart and reconnect that recreated a new folder ~/.vscode-server on the remote Linux machine, and now my client VS Code window finds its git and properly shows me a side window with all the changed files.

So, long story short, I guess the solution was to:

  1. Add git into $PATH on the remote, so that it's picked up right on user login (i.e. you don't have to execute ~/.profile or whatever manually).
  2. Recreate the connection and the ~/.vscode-server directory - I suspect that it may cache or store the $PATH or user session somewhere inside, so that's why it might not have picked up the changes from my .bashrc.

Also note that git.path option has no effect when working with SSH Remote: it shows a hint that it would only be effective when you open a local window, so I guess it's only relevant for your local git installation.

P.S. I know this question is 2 years old so perhaps the original author doesn't need this anymore, but I hope it will be useful for searchers like me, because I really didn't find any comprehensive info on this issue on the web.

Upvotes: 3

Related Questions