"Collection is read-only" error in newer (insider) Windows builds. This happens when installing any package.
Package installs and doesn't error.
This has happened across multiple machines.
Whoa... wtf Powershell?!
Turns out this doesn't repro with the latest Insider Preview build of Windows. I'll let you know if that changes.
@Tom999Hall this
Looks like the same - this is on the latest insider Preview - Win10 x64, Build 14291
I created an issue on this to get Microsoft's feedback - https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/13028523-lastest-windows-insider-builds-collection-is-rea
@scowalt @Tom999Hall if you upgrade to the latest beta of 0.9.10, are you still seeing this error?
I got the same error trying to upgrade

@Tom999Hall I just thought of that yeah. You try to use https://chocolatey.org/installabsolutelatest.ps1 and run the installer to get the beta.
Installed/upgraded to 0.9.10 beta Ok, but still getting
ERROR: Collection is read-only. at
Can you try isolating this for me?
Call:
& C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1 - there should be an error, I just want to get an idea if the above error is related to something in this script or another reason.
Add the error log or an image back here after you run this

Contents of the file?
Two things. Contents of the file and can you tell me the specific encoding of the file? (Notepad++ can provide this information easily). I'm looking for UTF-8 with or without BOM.
Actually, line 1 - we specify parameters in a script.
I just looked and the file for me is UTF w/BOM. So is the chocolateyInstaller.psm1 file.
DO me a huge favor.
Create these two files:
TestWithParams.ps1:
param (
[string]$TestVariable
)
$invocation = $MyInvocation
$argumentsPassed = $invocation.UnboundArguments -Join ' '
Write-Output "Received [$($invocation.InvocationName) $argumentsPassed]"
TestNoParams.ps1:
$invocation = $MyInvocation
$argumentsPassed = $invocation.UnboundArguments -Join ' '
Write-Output "Received [$($invocation.InvocationName) $argumentsPassed]"
Now run both as
& C:\TestWithParams -TestVariable 'Hi' -OtherArgument 'yep'& C:\TestNoParams -TestVariable 'Hi' -OtherArgument 'yep'This was my output:
PS C:\> & C:\code\temp\powershellparams\TestNoParams.ps1 -TestVariable 'Hi' -OtherArgument 'yep'
Received [& -TestVariable Hi -OtherArgument yep]
PS C:\> & C:\code\temp\powershellparams\TestWithParams.ps1 -TestVariable 'Hi' -OtherArgument 'yep'
Received [& -OtherArgument yep]
PS C:\> $host.version
Major Minor Build Revision
----- ----- ----- --------
2 0 -1 -1

PS C:\> & C:\code\temp\powershellparams\TestNoParams.ps1 -TestVariable 'Hi' -OtherArgument 'yep'
Received [& -TestVariable Hi -OtherArgument yep]
PS C:\> & C:\code\temp\powershellparams\TestWithParams.ps1 -TestVariable 'Hi' -OtherArgument 'yep'
Received [& -OtherArgument yep]
PS C:\> $host.version
Major Minor Build Revision
----- ----- ----- --------
3 0 -1 -1

PS C:\> & C:\code\temp\powershellparams\TestNoParams.ps1 -TestVariable 'Hi' -OtherArgument 'yep'
Received [& -TestVariable Hi -OtherArgument yep]
PS C:\> & C:\code\temp\powershellparams\TestWithParams.ps1 -TestVariable 'Hi' -OtherArgument 'yep'
Received [& -OtherArgument yep]
PS C:\> $host.version
Major Minor Build Revision
----- ----- ----- --------
4 0 -1 -1

PS C:\> & C:\code\temp\powershellparams\TestNoParams.ps1 -TestVariable 'Hi' -OtherArgument 'yep'
Received [& -TestVariable Hi -OtherArgument yep]
PS C:\> & C:\code\temp\powershellparams\TestWithParams.ps1 -TestVariable 'Hi' -OtherArgument 'yep'
Received [& -OtherArgument yep]
PS C:\> $host.version
Major Minor Build Revision
------- ------- ------- -----------
5 0 10240 16384


Here's mine ...

Well that validates it is not params. Okay, let's incrementally add parts of the chocolateyScriptRunner.ps1 into TestWithParams.ps1 one until we find the culprit. Can you do that for me?
Unfortunately, I鈥檝e got to go out for a couple of hours
No worries, it will be here when you get back.
https://github.com/chocolatey/choco/blob/0.9.9.11/src/chocolatey.resources/helpers/chocolateyScriptRunner.ps1 - If I had to guess, I'd believe it is $Warning that is causing the issue:
$RunNote = "DarkCyan"
$Warning = "Magenta"
$ErrorColor = "Red"
$Note = "Green"
@ferventcoder
Yes, bug in PowerShell in the latest insider build. Will get it fixed, in the meanwhile you can fix the issue on your side by changing (in file choco/src/chocolatey.resources/helpers/chocolateyScriptRunner.ps1)
From:
[alias("params")][alias("parameters")][alias("pkgParams")]
To:
[alias("params","parameters","pkgParams")]
Ah! Thanks @HemantMahawar!
This has been released in 0.9.9.12 and today's beta release for 0.9.10.
Thanks for addressing this so quickly @ferventcoder !
No worries. I didn't want to put out a 0.9.9.12 but this is a pretty gating issue for Choco, so I created the branch from the last tag and we'll have a short-lived 0.9.9.x branch.
As an aside, git is awesome. :+1:
(also, friendly reminder to update install.ps1 on the website :smile:)
Thanks, forgot that was changed to be hardcoded!
Done.
Quick note to anyone else pasting the fix from @HemantMahawar - the quotes are smart quotes (which is why your text search is failing). Thanks for the fix!
Fixed. Thanks for noting that @GeorgeHahn!
Most helpful comment
This has been released in 0.9.9.12 and today's beta release for 0.9.10.