Set-PSResourceRepository fails on first run when PSResourceGet store directory does not exist
@alerickson 已经在做这个了。
开始于 2026年8月13日。
评估
这个 Issue 还没有评估数据。
描述
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
Steps to reproduce
On a fresh Linux environment where the PSResourceGet store directory does not exist, run the following:
Import-Module Microsoft.PowerShell.PSResourceGet
Remove-Item -Recurse -Force /home/vscode/.local/share/PSResourceGet -ErrorAction SilentlyContinue
Set-PSResourceRepository -Name PSGallery -Trusted
I also encountered this during a brand new GitHub Codespaces/devcontainer build, where postCreateCommand runs Set-PSResourceRepository -Name PSGallery -Trusted. A minimal first-run repro is enough to trigger the same problem
Observed notes:
Get-PSResourceRepositorycan return the defaultPSGalleryrepository.Set-PSRepository -Name PSGallery -InstallationPolicy Trusteddoes not fail in the same environment.- Creating the parent directory manually makes the PSResourceGet command succeed:
After that, this succeeds:mkdir -p /home/vscode/.local/share/PSResourceGetSet-PSResourceRepository -Name PSGallery -Trusted
Expected behavior
Set-PSResourceRepository should succeed on first run and create any missing parent directory or repository store file needed for PSResourceGet state.
Actual behavior
Set-PSResourceRepository fails before it can initialize the repository store:
Cannot retrieve the dynamic parameters for the cmdlet. Loading repository store failed: Could not find a part of the path '/home/vscode/.local/share/PSResourceGet/PSResourceRepository.xml'.
In the devcontainer build log, the same failure aborts postCreateCommand entirely:
2026-03-19 02:43:19.647Z: Running the postCreateCommand from devcontainer.json...
2026-03-19 02:43:19.647Z: pwsh .devcontainer/install-dev-tools.ps1 && bash ./.devcontainer/workspace-repositories-clone.sh
2026-03-19 02:43:20.940Z: Set-PSResourceRepository: /workspaces/excloud-runbooks-ghemu/.devcontainer/install-dev-tools.ps1:5
Line |
5 | Set-PSResourceRepository -Name PSGallery -Trusted
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot retrieve the dynamic parameters for the cmdlet. Loading
| repository store failed: Could not find a part of the path
| '/home/vscode/.local/share/PSResourceGet/PSResourceRepository.xml'.
2026-03-19 02:43:21.041Z: postCreateCommand from devcontainer.json failed with exit code 1. Skipping any further user-provided commands.
Error details
PSMessageDetails :
Exception : System.Management.Automation.ParameterBindingException:
Cannot retrieve the dynamic parameters for the
cmdlet. Loading repository store failed: Could not
find a part of the path '/home/vscode/.local/share/PSRe
sourceGet/PSResourceRepository.xml'.
---> System.Management.Automation.PSInvalidOperationEx
ception: Loading repository store failed: Could not
find a part of the path '/home/vscode/.local/share/PSRe
sourceGet/PSResourceRepository.xml'.
at Microsoft.PowerShell.PSResourceGet.UtilClasses.Re
positorySettings.Read(String[] repoNames, String[]&
errorList) in C:\__w\1\s\PSResourceGet\src\code\Reposit
orySettings.cs:line 603
at Microsoft.PowerShell.PSResourceGet.Cmdlets.SetPSR
esourceRepository.GetDynamicParameters() in C:\__w\1\s\
PSResourceGet\src\code\SetPSResourceRepository.cs:line
112
at System.Management.Automation.CmdletParameterBinde
rController.HandleCommandLineDynamicParameters(Paramete
rBindingException& outgoingBindingException)
--- End of inner exception stack trace ---
at System.Management.Automation.ExceptionHandlingOps
.CheckActionPreference(FunctionContext funcContext,
Exception exception)
at System.Management.Automation.Interpreter.ActionCa
llInstruction`2.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTry
CatchFinallyInstruction.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTry
CatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject :
CategoryInfo : InvalidArgument: (:) [Set-PSResourceRepository],
ParameterBindingException
FullyQualifiedErrorId : GetDynamicParametersException,Microsoft.PowerShell.PSRe
sourceGet.Cmdlets.SetPSResourceRepository
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
Environment data
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Binary 1.2.0 Microsoft.PowerShell.PSResourceGet {Compress-PSResource, Find-PSResource, Get-InstalledPSResource, Get-PSResourceRepository…}
Name Value
---- -----
PSVersion 7.6.0
PSEdition Core
GitCommitId 7.6.0
OS Ubuntu 24.04.4 LTS
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.4
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
- 主要语言
- C#
- 星标
- 576
- 派生
- 114
- 平均合并
- 23 小时 17 分钟
- 30 天内合并 PR
- 8
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PowerShell/PSResourceGet 的其他 Issue
-
Create parent directories only after the containment check in InstallHelper.TryExtractToDirectory 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
PowerShell/PSResourceGet#2056 ·
-
feature_request
难度 2/5 1-3 小时 新手友好度 68/100
PowerShell/PSResourceGet#2013 · 3 条评论 ·
-
feature_request Needs-Triage
PowerShell/PSResourceGet#2057 · 已指派 1 人 ·
-
Needs-Triage
难度 3/5 1-2 天 新手友好度 68/100
PowerShell/PSResourceGet#2055 ·
-
Needs-Triage
难度 3/5 1-2 天 新手友好度 72/100
PowerShell/PSResourceGet#2054 ·
查看 PowerShell/PSResourceGet 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
-
type/automation type/tech-debt
难度 2/5 1-3 小时 新手友好度 78/100
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
-
t/bug
难度 2/5 1-3 小时 新手友好度 82/100
-
ci-failure-cause test-failure
难度 2/5 1-3 小时 新手友好度 82/100