在加载ssh-agent / git时,Powershell在启动时需要很长时间才能加载

时间:2022-10-19 18:33:01

I have Powershell set to use posh-git through Git for Windows. In my profile file I have this:

我将Powershell设置为通过Git for Windows使用posh-git。在我的个人资料文件中,我有这个:

# If Posh-Git environment is defined, load it.
. (Resolve-Path "$env:LOCALAPPDATA\GitHub\shell.ps1")
. $env:github_posh_git\profile.example.ps1

Every time I open Powershell it requests the passphrase for my id_rsa key. That's fine but it takes longer and longer to actually display the request. When I first set it up this way it prompted for the pass quite fast but the loading times increased over time.

每次打开Powershell时,它都会为我的id_rsa密钥请求密码。这很好,但实际显示请求需要更长时间。当我第一次以这种方式进行设置时,它提示传递非常快,但加载时间随着时间的推移而增加。

Any suggestions? I don't even know what to begin with in looking into this.

有什么建议么?我甚至不知道如何开始研究这个问题。

3 个解决方案

#1


4  

The problem is indeed slow setting of user environment variables. I recently merged a change that uses a temp file instead.

问题确实是用户环境变量的设置缓慢。我最近合并了一个使用临时文件的更改。

The latest GH4W (1.0.48.0) includes this change.

最新的GH4W(1.0.48.0)包含了这一变化。

#2


3  

I traced this problem down to this: https://superuser.com/questions/565771/setting-user-environment-variables-is-very-slow

我追溯到这个问题:https://superuser.com/questions/565771/setting-user-environment-variables-is-very-slow

Since chrome have many processes that takes time to response, I simply closed down Chrome in my profile.ps1 like this.

由于chrome有许多流程需要时间来响应,我只是在我的profile.ps1中关闭了Chrome。

$agent = Get-Process -Name ssh-agent -ErrorAction SilentlyContinue
$chrome = Get-Process -Name chrome -ErrorAction SilentlyContinue
$chromepath = $null
if(!$agent -and $chrome){
    Write-Host "Chrome is open, press any key to close"
    $host.UI.RawUI.ReadKey() | out-null
    $chromepath = $chrome[0].Path
    $chrome | Stop-Process
}
Start-SshAgent -Quiet

if($chromepath){
     Start-Process $chromepath
}

#3


1  

I had a similar problem (without passphrase requests). Reinstalling helped. It is the advice given here:

我有类似的问题(没有密码短语请求)。重新安装有帮助。这是给出的建议:

Eiter way, today I completely removed all traces of posh-git (including the entries in Microsoft.PowerShell_profile.ps1) and cloned it from source. This solved the problem for me!

Eiter方式,今天我完全删除了所有posh-git的痕迹(包括Microsoft.PowerShell_profile.ps1中的条目)并从源代码克隆它。这解决了我的问题!

#1


4  

The problem is indeed slow setting of user environment variables. I recently merged a change that uses a temp file instead.

问题确实是用户环境变量的设置缓慢。我最近合并了一个使用临时文件的更改。

The latest GH4W (1.0.48.0) includes this change.

最新的GH4W(1.0.48.0)包含了这一变化。

#2


3  

I traced this problem down to this: https://superuser.com/questions/565771/setting-user-environment-variables-is-very-slow

我追溯到这个问题:https://superuser.com/questions/565771/setting-user-environment-variables-is-very-slow

Since chrome have many processes that takes time to response, I simply closed down Chrome in my profile.ps1 like this.

由于chrome有许多流程需要时间来响应,我只是在我的profile.ps1中关闭了Chrome。

$agent = Get-Process -Name ssh-agent -ErrorAction SilentlyContinue
$chrome = Get-Process -Name chrome -ErrorAction SilentlyContinue
$chromepath = $null
if(!$agent -and $chrome){
    Write-Host "Chrome is open, press any key to close"
    $host.UI.RawUI.ReadKey() | out-null
    $chromepath = $chrome[0].Path
    $chrome | Stop-Process
}
Start-SshAgent -Quiet

if($chromepath){
     Start-Process $chromepath
}

#3


1  

I had a similar problem (without passphrase requests). Reinstalling helped. It is the advice given here:

我有类似的问题(没有密码短语请求)。重新安装有帮助。这是给出的建议:

Eiter way, today I completely removed all traces of posh-git (including the entries in Microsoft.PowerShell_profile.ps1) and cloned it from source. This solved the problem for me!

Eiter方式,今天我完全删除了所有posh-git的痕迹(包括Microsoft.PowerShell_profile.ps1中的条目)并从源代码克隆它。这解决了我的问题!