Scoop: `scoop install perl` fails: Cannot bind parameter 'Encoding'. Cannot convert the "byte" value of type "System.String" to type "System.Text.Encoding"

Created on 3 Jul 2018  路  3Comments  路  Source: lukesampson/scoop

> scoop install perl
Installing 'perl' (5.26.2.1) [64bit]
strawberry-perl-5.26.2.1-64bit-portable.zip (140.6 MB) [===================================================================================================] 100%
Checking hash of strawberry-perl-5.26.2.1-64bit-portable.zip... ok.
Extracting... done.
Linking ~\scoop\apps\perl\current => ~\scoop\apps\perl\5.26.2.1
Running post-install script...
Invoke-Expression : Cannot bind parameter 'Encoding'. Cannot convert the "byte" value of type "System.String" to type "System.Text.Encoding".
At C:\Users\jpoehls\scoop\apps\scoop\current\lib\install.ps1:900 char:9
+         Invoke-Expression (@($post_install) -join "`r`n")
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidArgument: (:) [Invoke-Expression], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.InvokeExpressionCommand
> scoop --version
Current Scoop version:
36fc8265 (HEAD -> master, origin/master, origin/HEAD) Update dotnet-sdk to version 2.1.301
> scoop info perl
Name: perl
Version: 5.26.2.1
Website: http://strawberryperl.com
License: GPL (https://spdx.org/licenses/GPL.html)
Manifest:
  C:\Users\jpoehls\scoop\apps\scoop\current\lib\..\bucket\perl.json
Installed:
  C:\Users\jpoehls\scoop\apps\perl\5.26.2.1
Environment:
  PATH=%PATH%;C:\Users\jpoehls\scoop\apps\perl\5.26.2.1\perl\site\bin
  PATH=%PATH%;C:\Users\jpoehls\scoop\apps\perl\5.26.2.1\perl\bin
  PATH=%PATH%;C:\Users\jpoehls\scoop\apps\perl\5.26.2.1\c\bin

```

$psversiontable

Name Value
---- -----
PSVersion 6.0.2
PSEdition Core
GitCommitId v6.0.2
OS Microsoft Windows 10.0.17134
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

bug powershell 6

Most helpful comment

I'll take a stab at fixing this. Should be easy enough to use [System.IO.File]::WriteAllBytes() instead of Set-Content and that would work consistently on both PowerShell 6 and earlier versions.

All 3 comments

I was not able to duplicate this.

PS> $psversiontable

Name                           Value
----                           -----
PSVersion                      5.1.14409.1012
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1012
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

It looks like this is because Set-Content ... -Encoding Byte has been removed in PowerShell 6. It is replaced by Set-Content ... -AsByteStream.

Source: https://www.jonathanmedd.net/2017/12/powershell-core-does-not-have-encoding-byte-replaced-with-new-parameter-asbytestream.html

I'll take a stab at fixing this. Should be easy enough to use [System.IO.File]::WriteAllBytes() instead of Set-Content and that would work consistently on both PowerShell 6 and earlier versions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

borekb picture borekb  路  3Comments

brunovieira97 picture brunovieira97  路  3Comments

yetangye picture yetangye  路  3Comments

Decem6er picture Decem6er  路  3Comments

SinisterBlade picture SinisterBlade  路  3Comments