PSFzf icon indicating copy to clipboard operation
PSFzf copied to clipboard

Failed to import module

Open Karmenzind opened this issue 2 years ago • 9 comments

It seems that the syntax of PSFzf code is not supported by my Powershell.

> Import-Module PSReadline
> Import-Module PSFzf
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psm1:1407 char:61
+         Bind          = @('ctrl-/:change-preview-window(down,50%,bord ...
+                                                             ~
Missing argument in parameter list.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psm1:1407 char:84
+ ...      = @('ctrl-/:change-preview-window(down,50%,border-top|hidden|)')
+                                                                       ~
An empty pipe element is not allowed.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psm1:1542 char:43
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                           ~
Missing ] at end of attribute or type literal.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psm1:1542 char:49
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                                 ~
Unexpected token ']' in expression or statement.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psm1:1542 char:49
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                                 ~
Missing closing ')' in expression.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psm1:1315 char:9
+     try {
+         ~
Missing closing '}' in statement block or type definition.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psm1:1542 char:51
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                                   ~
The Try statement is missing its Catch or Finally block.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psm1:1307 char:32
+ function Invoke-PsFzfRipgrep() {
+                                ~
Missing closing '}' in statement block or type definition.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psm1:1542 char:51
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                                   ~
Unexpected token ')' in expression or statement.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psm1:1565 char:43
+     $fzfArguments['PreviewWindow'] = 'down,border-top,40%'
+                                           ~
Missing argument in parameter list.
Not all parse errors were reported.  Correct the reported errors and try again.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingArgument

Import-Module : The module to process 'PSFzf.psm1', listed in field 'ModuleToProcess/RootModule' of module manifest 'C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psd1' was not processed because no valid module was found in any modu le directory.
At line:1 char:62
+ ... Thread]::CurrentThread.CurrentUICulture = 'en-US';Import-Module PSFzf
+                                                       ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (PSFzf:String) [Import-Module], PSInvalidOperationException
    + FullyQualifiedErrorId : Modules_ModuleFileNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand


λ  echo $PSVersionTable

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

But the module worked fine on another Windows in which PS version is also 5.1:

λ  echo $PSVersionTable

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

Karmenzind avatar Sep 15 '22 07:09 Karmenzind

I tried powershell 7.2 and it worked.

Karmenzind avatar Sep 15 '22 11:09 Karmenzind

Same problem

所在位置 C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psm1:1407 字符: 61
+         Bind          = @('ctrl-/:change-preview-window(down,50%,bord ...
+                                                             ~
参数列表中缺少参量。
所在位置 C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psm1:1407 字符: 84
+ ...      = @('ctrl-/:change-preview-window(down,50%,border-top|hidden|)')
+                                                                       ~
不允许使用空管道元素。
所在位置 C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psm1:1542 字符: 43
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                           ~
属性或类型文本末尾缺少 ]。
所在位置 C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psm1:1542 字符: 49
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                                 ~
表达式或语句中包含意外的标记“]”。
所在位置 C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.10\PSFzf.psm1:1542 字符: 49

TYZRPVX avatar Sep 25 '22 10:09 TYZRPVX

I tried powershell 7.2 and it worked.

poweshell 7 works but it breaks other scripts that support only powershell 5. Which version supports powershell 5?

madjxatw avatar Nov 06 '22 12:11 madjxatw

same problem when in ps 5.1 import-module PSFzf

safeblood avatar Jan 09 '23 05:01 safeblood

I can't recreate this issue locally.

  • Can someone share their $PROFILE?
  • What Windows OS are you see this issue?

kelleyma49 avatar Jan 14 '23 19:01 kelleyma49

` Import-Module "PowerTab" -ArgumentList "C:\Users\xxx\Documents\WindowsPowerShell\PowerTabConfig.xml" [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 Import-Module PowerLine Import-Module -Name Terminal-Icons Import-Module PSUtil Import-Module PSEverything

Import-Module ZLocation Write-Host -Foreground Green "n[ZLocation] knows about $((Get-ZLocation).Keys.Count) locations.n" Import-Module PSReadLine $PSReadLineOptions = @{ EditMode = "Vi" PredictionViewStyle = "ListView" } Set-PSReadLineOption @PSReadLineOptions Import-Module posh-git `

safeblood avatar Jan 17 '23 04:01 safeblood

1)$profile Import-Module PSReadLine Import-Module PSFzf

Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r'

2)scoop install fzf fzf --version 0.38.0 (352ea07)

3)$host

Name : ConsoleHost Version : 5.1.19041.2364 InstanceId : e2f0a2e3-c6a2-4632-ade2-f741ed04d040 UI : System.Management.Automation.Internal.Host.InternalHostUserInterface CurrentCulture : en-US CurrentUICulture : en-US PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy DebuggerEnabled : True IsRunspacePushed : False Runspace : System.Management.Automation.Runspaces.LocalRunspace

4) Windows OS

Edition Windows 10 Enterprise Version 21H2 Installed on ‎08/‎15/‎2020 OS build 19044.2486 Experience Windows Feature Experience Pack 120.2212.4190.0

5)Import-Module PSFzf

At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1408 char:61
+         Bind          = @('ctrl-/:change-preview-window(down,50%,bord ...
+                                                             ~
Missing argument in parameter list.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1408 char:84
+ ...      = @('ctrl-/:change-preview-window(down,50%,border-top|hidden|)')
+                                                                       ~
An empty pipe element is not allowed.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1557 char:43
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                           ~
Missing ] at end of attribute or type literal.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1557 char:49
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                                 ~
Unexpected token ']' in expression or statement.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1557 char:49
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                                 ~
Missing closing ')' in expression.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1316 char:9
+     try {
+         ~
Missing closing '}' in statement block or type definition.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1557 char:51
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                                   ~
The Try statement is missing its Catch or Finally block.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1308 char:32
+ function Invoke-PsFzfRipgrep() {
+                                ~
Missing closing '}' in statement block or type definition.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1557 char:51
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                                   ~
Unexpected token ')' in expression or statement.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1576 char:43
+     $fzfArguments['PreviewWindow'] = 'down,border-top,40%'
+                                           ~
Missing argument in parameter list.
Not all parse errors were reported.  Correct the reported errors and try again.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingArgument

Import-Module : The module to process 'PSFzf.psm1', listed in field 'ModuleToProcess/RootModule' of module manifest 'C:\Program
Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psd1' was not processed because no valid module was found in any module directory.
At line:1 char:1
+ Import-Module PSFzf
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (PSFzf:String) [Import-Module], PSInvalidOperationException
    + FullyQualifiedErrorId : Modules_ModuleFileNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

gigberg avatar Feb 26 '23 09:02 gigberg

1)$profile Import-Module PSReadLine Import-Module PSFzf

Set-PsFzfOption -PSReadlineChordProvider 'Ctrl+t' -PSReadlineChordReverseHistory 'Ctrl+r'

2)scoop install fzf fzf --version 0.38.0 (352ea07)

3)$host

Name : ConsoleHost Version : 5.1.19041.2364 InstanceId : e2f0a2e3-c6a2-4632-ade2-f741ed04d040 UI : System.Management.Automation.Internal.Host.InternalHostUserInterface CurrentCulture : en-US CurrentUICulture : en-US PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy DebuggerEnabled : True IsRunspacePushed : False Runspace : System.Management.Automation.Runspaces.LocalRunspace

4) Windows OS

Edition Windows 10 Enterprise Version 21H2 Installed on ‎08/‎15/‎2020 OS build 19044.2486 Experience Windows Feature Experience Pack 120.2212.4190.0

5)Import-Module PSFzf

At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1408 char:61
+         Bind          = @('ctrl-/:change-preview-window(down,50%,bord ...
+                                                             ~
Missing argument in parameter list.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1408 char:84
+ ...      = @('ctrl-/:change-preview-window(down,50%,border-top|hidden|)')
+                                                                       ~
An empty pipe element is not allowed.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1557 char:43
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                           ~
Missing ] at end of attribute or type literal.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1557 char:49
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                                 ~
Unexpected token ']' in expression or statement.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1557 char:49
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                                 ~
Missing closing ')' in expression.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1316 char:9
+     try {
+         ~
Missing closing '}' in statement block or type definition.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1557 char:51
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                                   ~
The Try statement is missing its Catch or Finally block.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1308 char:32
+ function Invoke-PsFzfRipgrep() {
+                                ~
Missing closing '}' in statement block or type definition.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1557 char:51
+         if ($_ -match '\d\d-\d\d-\d\d\s+([a-f0-9]+)\s+') {
+                                                   ~
Unexpected token ')' in expression or statement.
At C:\Program Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psm1:1576 char:43
+     $fzfArguments['PreviewWindow'] = 'down,border-top,40%'
+                                           ~
Missing argument in parameter list.
Not all parse errors were reported.  Correct the reported errors and try again.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingArgument

Import-Module : The module to process 'PSFzf.psm1', listed in field 'ModuleToProcess/RootModule' of module manifest 'C:\Program
Files\WindowsPowerShell\Modules\PSFzf\2.5.16\PSFzf.psd1' was not processed because no valid module was found in any module directory.
At line:1 char:1
+ Import-Module PSFzf
+ ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (PSFzf:String) [Import-Module], PSInvalidOperationException
    + FullyQualifiedErrorId : Modules_ModuleFileNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

solved by install-module psfzf with old version Install-Module -Name PSFzf -RequiredVersion 2.0.0

gigberg avatar Feb 26 '23 16:02 gigberg

Thanks @gigberg . Uninstall 2.5 and install 2.0.0 resolved my issue!

lincank avatar Mar 18 '23 02:03 lincank