简体   繁体   English

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

[英]Powershell takes a long time to load on start-up while loading ssh-agent / git

I have Powershell set to use posh-git through Git for Windows. 我有Powershell设置通过Git for Windows使用posh-git。 In my profile file I have this: 在我的个人资料文件中,我有这个:

# 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. 每次打开Powershell时,它都会为我的id_rsa密钥请求密码。 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. 当我第一次以这种方式设置它时,它提示传递非常快,但加载时间随着时间的推移而增加。

Any suggestions? 有什么建议? I don't even know what to begin with in looking into this. 我甚至不知道如何开始研究这个问题。

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)包含了这一变化。

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
}

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. Eiter方式,今天我完全删除了所有posh-git的痕迹(包括Microsoft.PowerShell_profile.ps1中的条目)并从源代码克隆它。 This solved the problem for me! 这解决了我的问题!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM