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

2.0.x won't import in Windows PowerShell #22

Closed
Windos opened this issue Mar 18, 2019 · 1 comment
Closed

2.0.x won't import in Windows PowerShell #22

Windos opened this issue Mar 18, 2019 · 1 comment
Labels
🐛 bug Confirmed bugs or pull requests resolving them 👏 good first issue Good for newcomers

Comments

@Windos
Copy link

Windos commented Mar 18, 2019

(n.b. not sure if current releases are meant to drop support for Windows PowerShell?)

The latest release uses a syntax on Join-Path that won't work in Windows PowerShell, and and automatic variable that also doesn't exist in Windows PowerShell.

Trying to import the module results in:

Join-Path : A positional parameter cannot be found that accepts argument 'SkiaSharp.dll'.
At C:\Users\Windos\Documents\WindowsPowerShell\Modules\pswordcloud\2.0.1\PSWordCloud.psm1:13 char:16
+ ... iaDllPath = Join-Path -Path $PSScriptRoot -ChildPath $PlatformFolder  ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Join-Path], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.JoinPathCommand

Add-Type : Cannot bind argument to parameter 'Path' because it is null.
At C:\Users\Windos\Documents\WindowsPowerShell\Modules\pswordcloud\2.0.1\PSWordCloud.psm1:15 char:16
+ Add-Type -Path $SkiaDllPath
+                ~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Type], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddTypeCommand

Import-Module : Could not load file or assembly 'SkiaSharp, Version=1.68.0.0, Culture=neutral,
PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The system cannot find the file specified.
At C:\Users\Windos\Documents\WindowsPowerShell\Modules\pswordcloud\2.0.1\PSWordCloud.psm1:16 char:1
+ Import-Module  "$PSScriptRoot\PSWordCloudCmdlet.dll"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand

This is coming from this line in the psm1 file:

$SkiaDllPath = Join-Path -Path $PSScriptRoot -ChildPath $PlatformFolder "SkiaSharp.dll"

Possible fixes are to change the child path to "$PlatformFolder\SkiaSharp.dll"or two swap outJoin-Pathfor[http://System.IO .Path]::Combine()`

However, this change highlights a second issue, the switch statement for Platform Folder selection relies on PowerShell Core as $IsWindows isn't a thing in Windows PowerShell.

Add-Type : Cannot bind parameter 'Path' to the target. Exception setting "Path": "Cannot find path
'C:\Users\Windos\Documents\WindowsPowerShell\Modules\pswordcloud\2.0.1\SkiaSharp.dll' because it does not exist."
At C:\Users\Windos\Documents\WindowsPowerShell\Modules\pswordcloud\2.0.1\PSWordCloud.psm1:15 char:16
+ Add-Type -Path $SkiaDllPath
+                ~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Add-Type], ParameterBindingException
    + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.PowerShell.Commands.AddTypeCommand

Import-Module : Could not load file or assembly 'SkiaSharp, Version=1.68.0.0, Culture=neutral,
PublicKeyToken=0738eb9f132ed756' or one of its dependencies. The system cannot find the file specified.
At C:\Users\Windos\Documents\WindowsPowerShell\Modules\pswordcloud\2.0.1\PSWordCloud.psm1:16 char:1
+ Import-Module  "$PSScriptRoot\PSWordCloudCmdlet.dll"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand

How we dealt with this in PoshNotify is putting the Windows PowerShell specific stuff in a "default" stanza (even though it duplicates the "IsWindows" stanza) so that we can do specific stuff for that platform in future if required.

@vexx32
Copy link
Owner

vexx32 commented Mar 18, 2019

Great points, thank you!

I had originally planned to just drop support for Windows PowerShell anyway, but later decided there wasn't a compelling reason to do so just yet. It's a tempting thought still and might happen eventually, but for now I figure I may as well support it.

Thank you for the detailed analysis; feel free to submit a PR if you'd like, but if you don't have time I can take care of it in the next few days. 😄

@vexx32 vexx32 added 🐛 bug Confirmed bugs or pull requests resolving them 👏 good first issue Good for newcomers labels Mar 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Confirmed bugs or pull requests resolving them 👏 good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants