Working with private packages via SSH in vscode on Windows 11

On a fresh Windows 11 machine I’m trying to add private package (or private registry) via SSH and found that vscode terminal works differently from external Julia terminal.

I followed instructions from LocalRegistry.jl .

Generated and added SSH key to github account :
ssh-keygen -t rsa -b 4096 -m PEM

Added the following line in ~/.julia/config/startup.jl

ENV["JULIA_PKG_USE_CLI_GIT"]=true

In external Julia console (started from Git Bash or Powershell) I can add private package:

(test_julia_env) pkg> add git@github.com:sairus7/MyPrivatePackage.jl.git
     Cloning git-repo `git@github.com:sairus7/MyPrivatePackage.jl.git`
    Updating git-repo `git@github.com:sairus7/MyPrivatePackage.jl.git`
   Resolving package versions...

But in vscode console (started from command pallete: F1 - Julia: Start REPL) I have an error:

(test_julia_env) pkg> add git@github.com:sairus7/MyPrivatePackage.jl.git
    Updating git-repo `git@github.com:sairus7/MyPrivatePackage.jl.git`
ERROR: The command `git fetch -q git@github.com:sairus7/MyPrivatePackage.jl.git '+refs/*:refs/remotes/cache/*'` failed, error: Base.IOError("could not spawn `git fetch -q git@github.com:sairus7/MyPrivatePackage.jl.git '+refs/*:refs/remotes/cache/*'`: no such file or directory (ENOENT)", -4058)

Are there any vscode-specific settings that change git cli behaviour? Or should I add JULIA_PKG_USE_CLI_GIT somewhere else in vscode settings?

UPD:

However, some time ago I had no problems with JULIA_PKG_USE_CLI_GIT from vscode, so maybe there are some changes with git behaviour? Forcing git to use system-wide OenSSH didn’t help:

git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe"

For now it works in both consoles only if I remove JULIA_PKG_USE_CLI_GIT and add the following lines in ~/.julia/config/startup.jl :

ENV["SSH_PUB_KEY_PATH"] = joinpath(homedir(), ".ssh", "id_rsa.pub")
ENV["SSH_KEY_PATH"] = joinpath(homedir(), ".ssh", "id_rsa")

FWIW, “Could not spawn” suggests to me it is trying to use the CLI git but can’t find it. From the Julia session you’re trying this in, if you use the shell prompt, can you run a git command? Can you do it from a PowerShell inside VS Code?

You are right! PowerShell inside VS Code can’t find git. But it is found from external shell. C:\Program Files\Git\cmd is added to PATH.

So, vscode has somewhere an extra layer of environment isolation?

Looks like a simple reboot solved the problem. :slight_smile:

1 Like