簡體   English   中英

Visual Studio 2019 git 問題:“無法生成... ssh.exe:在獲取/推送時沒有此類文件或目錄”

[英]Visual Studio 2019 git problem: "Cannot spawn ... ssh.exe: No such file or directory" on fetch/push

無法讓 VS2019 獲取/推送到遠程(恰好在 GitLab 上)。 什么是正確的配置?

  1. 我正在使用內置的 Windows 10 OpenSSH ( C:\Windows\System32\OpenSSH )

  2. 我已經設置了 env var GIT_SSH=C:\Windows\System32\OpenSSH\ssh.exe

  3. 私鑰通過ssh-add加載到正在運行的ssh-agent服務中。

  4. 從普通命令 window (即,不是 WSL bash shell)我可以推送/獲取到我心中的喜悅。

  5. 從 VS2019 開始,打開存儲庫( Git>Local Repositories>myrepo ),當我嘗試Git>FetchGit>Push時,我在 output window 中得到以下信息:

     Commit eebc0b4a created locally in repository r:\bbits\edu-bitcoin-staging Opening repositories: r:\bbits\edu-bitcoin-staging Pushing master Pushing to gitlab.com:bakins-bits/edu-bitcoin-staging.git Error: cannot spawn C:\Windows\System32\OpenSSH\ssh.exe: No such file or directory Error encountered while pushing to the remote repository: Git failed with a fatal error. Git failed with a fatal error. unable to fork Failed to push to the remote repository. See the Output window for more details.

注意C:\Windows\System32\OpenSSH\ssh.exe: No such file or directory - 然而,這是正確的路徑:

C:\>dir C:\Windows\System32\OpenSSH\ssh.exe
 Volume in drive C is P70-MSVC
 Volume Serial Number is 8240-9525

 Directory of C:\Windows\System32\OpenSSH

10/15/2019  06:50 AM           882,688 ssh.exe
               1 File(s)        882,688 bytes
               0 Dir(s)  333,358,600,192 bytes free

首先檢查來自 VS2019 的相同推/拉是否適用於在 session 中啟動的 VS2019,其中:

  • 設置GIT_SSH
  • ssh.exe is in %PATH% (meaning, before launching VS2019, a " where ssh " should return C:\Windows\System32\OpenSSH\ssh.exe first, before C:\path\to\Git\usr\bin\ssh.exe )

我不需要為這些操作設置GIT_SSH

使用它來逃避“程序文件”中的空間

git config --global core.sshCommand 'C:\\PROGRA~1\\\\Git\\usr\\bin\\ssh.exe'

我想我已經設法解決了這里的問題。 內置 Windows 10 OpenSSH是 64 位程序。 但是在 Visual Studio 中運行的 Git 是 32 位的。 Visual Studio 使用C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin"中的那個(根據您的 VS 版本調整路徑)。

問題是,Windows 使用虛擬文件夾來防止 32 位程序訪問 64 位庫。 因此,如果 32 位應用程序嘗試訪問System32文件夾,它會被重定向到SysWOW64 而且那里沒有OpenSSH 您可以通過嘗試從32-bit powershell window 訪問OpenSSH文件夾來模擬:

> cd C:\Windows\System32\OpenSSH\ssh.exe

您要做的是將GIT_SSH設置為

C:\Windows\SysNative\OpenSSH\ssh.exe

SysNative 是一個虛擬文件夾,它在物理上並不存在於您的系統中。 但是通過訪問它,程序不會被重定向到SysWOW64

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM