Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when installing package: "Collection is read-only" #659

Closed
scowalt opened this issue Mar 13, 2016 · 34 comments
Closed

Error when installing package: "Collection is read-only" #659

scowalt opened this issue Mar 13, 2016 · 34 comments

Comments

@scowalt
Copy link

scowalt commented Mar 13, 2016

What You Are Seeing?

"Collection is read-only" error in newer (insider) Windows builds. This happens when installing any package.

capture

What is Expected?

Package installs and doesn't error.

How Did You Get This To Happen? (Steps to Reproduce)

  1. Install latest Windows Insider build.
  2. Install chocolatey
  3. Attempt to install any package

This has happened across multiple machines.

Output Log

https://gist.github.com/scowalt/5cfc70636850df7cb5f9

@ferventcoder
Copy link
Member

Whoa... wtf Powershell?!

@scowalt
Copy link
Author

scowalt commented Mar 16, 2016

Turns out this doesn't repro with the latest Insider Preview build of Windows. I'll let you know if that changes.

@scowalt scowalt closed this as completed Mar 16, 2016
@ferventcoder
Copy link
Member

@Tom999Hall this

@Tom999Hall
Copy link

Looks like the same - this is on the latest insider Preview - Win10 x64, Build 14291

@ferventcoder ferventcoder reopened this Mar 18, 2016
@ferventcoder
Copy link
Member

@ferventcoder
Copy link
Member

@scowalt @Tom999Hall if you upgrade to the latest beta of 0.9.10, are you still seeing this error?

@Tom999Hall
Copy link

I got the same error trying to upgrade
chocolatey beta

@ferventcoder
Copy link
Member

@ferventcoder
Copy link
Member

@Tom999Hall I just thought of that yeah. You try to use https://chocolatey.org/installabsolutelatest.ps1 and run the installer to get the beta.

@Tom999Hall
Copy link

Installed/upgraded to 0.9.10 beta Ok, but still getting
ERROR: Collection is read-only. at , : line 1

@ferventcoder
Copy link
Member

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.

@ferventcoder
Copy link
Member

Add the error log or an image back here after you run this

@Tom999Hall
Copy link

chocolateyscriptrunner

@ferventcoder
Copy link
Member

Contents of the file?

@ferventcoder
Copy link
Member

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.

@ferventcoder
Copy link
Member

Actually, line 1 - we specify parameters in a script.

@ferventcoder
Copy link
Member

I just looked and the file for me is UTF w/BOM. So is the chocolateyInstaller.psm1 file.

@ferventcoder
Copy link
Member

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'

@ferventcoder
Copy link
Member

This was my output:

Posh v2

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

PowerShell v2 output

Posh v3

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

PowerShell v3 output

Posh v4

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

PowerShell v4 output

Posh v 5.0.10240.16384 (the default version shipping in Windows 10)

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

PowerShell v 5.0.10240.16384 output

Posh v 5.0.10514.6 (WMF 5 Final)

PowerShell v 5.0.10514.6 output

@Tom999Hall
Copy link

Here's mine ...
test powershell scripts

@ferventcoder
Copy link
Member

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?

@Tom999Hall
Copy link

Unfortunately, I’ve got to go out for a couple of hours

@ferventcoder
Copy link
Member

No worries, it will be here when you get back.

@ferventcoder
Copy link
Member

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"

@HemantMahawar
Copy link

HemantMahawar commented Mar 18, 2016

@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")]

@ferventcoder
Copy link
Member

Ah! Thanks @HemantMahawar!

@ferventcoder ferventcoder self-assigned this Mar 18, 2016
@ferventcoder ferventcoder added this to the 0.9.9.12 milestone Mar 18, 2016
ferventcoder added a commit that referenced this issue Mar 18, 2016
This bug in PowerShell is in the recent Windows Insider Build regarding
adding multiple aliases separately. You can specify the alias parameter
once and it will work with multiple values. This is a better way of
going about it anyway.
ferventcoder added a commit to ferventcoder/choco that referenced this issue Mar 18, 2016
This bug in PowerShell is in the recent Windows Insider Build regarding
adding multiple aliases separately. You can specify the alias parameter
once and it will work with multiple values. This is a better way of
going about it anyway.
ferventcoder added a commit to ferventcoder/choco that referenced this issue Mar 18, 2016
* 0.9.9.x:
  (version) 0.9.9.12
  (chocolateyGH-659) Fix: PowerShell Collection is read-only

# Conflicts:
#	.uppercut
#	CHANGELOG.md
#	nuget/chocolatey/chocolatey.nuspec
ferventcoder added a commit to ferventcoder/choco that referenced this issue Mar 18, 2016
* stable:
  (version) 0.9.9.12
  (chocolateyGH-659) Fix: PowerShell Collection is read-only
  (chocolateyGH-659) Fix: PowerShell Collection is read-only
ferventcoder added a commit that referenced this issue Mar 18, 2016
* 0.9.9.x:
  (GH-659) correct missing parentheses
ferventcoder added a commit that referenced this issue Mar 18, 2016
* stable:
  (GH-659) correct missing parentheses
@ferventcoder
Copy link
Member

This has been released in 0.9.9.12 and today's beta release for 0.9.10.

@scowalt
Copy link
Author

scowalt commented Mar 18, 2016

Thanks for addressing this so quickly @ferventcoder !

@ferventcoder
Copy link
Member

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. 👍

@scowalt
Copy link
Author

scowalt commented Mar 18, 2016

(also, friendly reminder to update install.ps1 on the website 😄)

@ferventcoder
Copy link
Member

Thanks, forgot that was changed to be hardcoded!

@ferventcoder
Copy link
Member

Done.

@GeorgeHahn
Copy link

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!

@ferventcoder
Copy link
Member

Fixed. Thanks for noting that @GeorgeHahn!

hjungG pushed a commit to hjungG/chocolatey that referenced this issue Apr 27, 2016
hjungG added a commit to hjungG/chocolatey that referenced this issue Apr 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants