我有一个本地 PowerShell 库,我将其重命名为 JnPSGallery。
我注销了旧路径 \\\Ryzen\G$\JnPowerShellGallery
然后注册新路径\\\Ryzen\G$\JnPSGallery
,但是当我使用 Update-Module 命令时,PowerShell 5 仍在尝试查找旧路径。我什至尝试注销所有存储库,然后输入 Update-Module 以查看会发生什么。
我收到错误“PackageManagement\Install-Package : Unable to find repository \\\Ryzen\G$\JnPowerShellGallery
.使用Get-PSRepository
查看所有可用的存储库。即使所有存储库都未注册,它仍在寻找旧的 PowerShell 库路径。
注册新的 JnPSGallery 路径后更新模块。
https://i.imgur.com/SOgk3zn.png
删除所有已注册的存储库后更新模块。
https://i.imgur.com/ZFTi0ut.png
如何阻止 PowerShell 5 尝试使用旧路径 \\\Ryzen\G$\JnPowerShellGallery
?
最佳答案
感谢您的帮助乔尔和阿德里安安德森。我解决了我的问题!
乔尔在 http://slack.poshcode.org/ powershell-help channel 建议我安装的一些模块可能仍在引用我的旧 PSGallery 路径。他是对的!
当我今天早上醒来时,我打开了 PowerShell 5,输入了 Get-InstalledModule,就在我面前的是仍然引用我的旧 PSGallery 路径的两个模块。我卸载了这些模块,错误就消失了。
我原本以为问题出在 PowerShellGet 模块上。我现在觉得很傻。
Get-InstalledModule 显示两个引用旧库的模块。
https://i.imgur.com/TWFtWcP.png
感谢 Joel,它使我免于重新安装 Windows。
关于powershell - 为什么 PowerShell 5 在重命名后仍在寻找旧的 PowerShell Gallery 路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58348897/