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

PowerTab does not work on Powershell Core on *Nix #112

Open
pshirshov opened this issue Sep 21, 2020 · 1 comment
Open

PowerTab does not work on Powershell Core on *Nix #112

pshirshov opened this issue Sep 21, 2020 · 1 comment

Comments

@pshirshov
Copy link

work/tut/ni-sshj-test via ☕ v11.0.8 on ☁️  eu-west-1 took 1m15s
❯ pwsh
PowerShell 7.0.3
Copyright (c) Microsoft Corporation. All rights reserved.

https://aka.ms/powershell
Type 'help' to get help.

MethodInvocationException: /Users/pavel/.local/share/powershell/Modules/PowerTab/1.1.0/PowerTab.psm1:10
Line |
  10 |      [Void][System.Reflection.Assembly]::LoadWithPartialName("System.W …
     |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Exception calling "LoadWithPartialName" with "1" argument(s): "Could not load file or assembly
     | 'System.Windows.Forms, Culture=neutral, PublicKeyToken=null'. Operation is not supported. (0x80131515)"


Launch the setup wizard to create a PowerTab configuration file and database?
PowerTab can be setup manually without the setup wizard.
[N] No  [Y] Yes  [?] Help (default is "Y"):

Where should the PowerTab configuration file and database be saved?
Any existing PowerTab configuration will be overwritten.
[P] Profile Directory  [I] Installation Directory  [A] Application Data Directory  [S] Isolated Storage  [O] Other Directory
[?] Help(default is "P"):

Update current profile to automatically import PowerTab?
To manually update the current profile or another profile, select 'No'.
[N] No  [Y] Yes  [?] Help (default is "Y"):
Get-Content: /Users/pavel/.local/share/powershell/Modules/PowerTab/1.1.0/TabExpansionUtil.ps1:701
Line |
 701 |          [Byte[]]$byte = Get-Content -Encoding Byte -ReadCount 4 -Tota …
     |                                                ~~~~
     | Cannot process argument transformation on parameter 'Encoding'. 'Byte' is not a supported encoding name. For
     | information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
     | (Parameter 'name')


Update .NET type list in tab completion database from currently loaded types?
Loading .NET types.
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):
                                                                                                                                      Update WMI class list in tab completion database?                                                                                     Loading WMI classes.                                                                                                                  [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):                                               New-Object: /Users/pavel/.local/share/powershell/Modules/PowerTab/1.1.0/TabExpansionLib.ps1:693                                       Line |                                                                                                                                 693 |          $Options = New-Object System.Management.EnumerationOptions                                                                 |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                 | Exception calling ".ctor" with "0" argument(s): "System.Management currently is only supported for Windows desktop                  | applications."                                                                                                                                                                                                                                                       InvalidOperation: /Users/pavel/.local/share/powershell/Modules/PowerTab/1.1.0/TabExpansionLib.ps1:694                                 Line |                                                                                                                                 694 |          $Options.EnumerateDeep = $true                                                                                             |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                             | The property 'EnumerateDeep' cannot be found on this object. Verify that the property exists and can be set.                                                                                                                                                         InvalidOperation: /Users/pavel/.local/share/powershell/Modules/PowerTab/1.1.0/TabExpansionLib.ps1:695                                 Line |                                                                                                                                 695 |          $Options.UseAmendedQualifiers = $true                                                                                      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                                                      | The property 'UseAmendedQualifiers' cannot be found on this object. Verify that the property exists and can be set.                                                                                                                                                  InvalidOperation: /Users/pavel/.local/share/powershell/Modules/PowerTab/1.1.0/TabExpansionLib.ps1:698                                 Line |                                                                                                                                 698 |          foreach ($Class in (([WmiClass]'').PSBase.GetSubclasses($Opti …                                                            |                                ~~~~~~~~                                                                                             | Unable to find type [WmiClass].                                                                                                                                                                                                                                                                                                                                                                            Update COM class list in tab completion database?                                                                                     Loading COM classes.                                                                                                                  [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):
Get-CimInstance: /Users/pavel/.local/share/powershell/Modules/PowerTab/1.1.0/TabExpansionLib.ps1:718                                  Line |                                                                                                                                 718 |          foreach ($Class in (Get-CimInstance -ClassName "Win32_Classic …                                                            |                              ~~~~~~~~~~~~~~~                                                                                        | The term 'Get-CimInstance' is not recognized as the name of a cmdlet, function, script file, or operable program.                   | Check the spelling of the name, or if a path was included, verify that the path is correct and try again.                                                                                                                                                                                                                                                                                                  Update computer list in tab completion database from 'net view'?                                                                      Loading computer names.                                                                                                               [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):

Launch the setup wizard to create a PowerTab configuration file and database?
PowerTab can be setup manually without the setup wizard.
[N] No  [Y] Yes  [?] Help (default is "Y"):

Where should the PowerTab configuration file and database be saved?
Any existing PowerTab configuration will be overwritten.
[P] Profile Directory  [I] Installation Directory  [A] Application Data Directory  [S] Isolated Storage  [O] Other Directory
[?] Help(default is "P"):

Update .NET type list in tab completion database from currently loaded types?
Loading .NET types.
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):
                                                                                                                                      Update WMI class list in tab completion database?                                                                                     Loading WMI classes.                                                                                                                  [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):                                                                                                                                                                                     Update COM class list in tab completion database?                                                                                     Loading COM classes.                                                                                                                  [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):                                                                                                                                                                                     Update computer list in tab completion database from 'net view'?                                                                      Loading computer names.                                                                                                               [Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):

PowerTab version 1.1.0 PowerShell TabExpansion Library
Host: ConsoleHost
PowerTab Enabled: True
Add-TabExpansionComputer: /Users/pavel/.local/share/powershell/Modules/PowerTab/1.1.0/TabExpansionLib.ps1:548
Line |
 548 |              Add-TabExpansionComputer -NetView
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The term 'net' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
     | spelling of the name, or if a path was included, verify that the path is correct and try again.


PowerTab version 1.1.0 PowerShell TabExpansion Library
Host: ConsoleHost
PowerTab Enabled: True
Loading personal and system profiles took 47824ms.
@disco0
Copy link

disco0 commented Apr 27, 2021

It seems the main PowerTab module is using Forms (Windows only, I believe):

## Load forms library when not loaded
if (-not ([AppDomain]::CurrentDomain.GetAssemblies() | Where-Object {$_.ManifestModule -like "System.Windows.Forms*"})) {
[Void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
}

You could try commenting out this line in your installed version, or (probably better) see if the PowerTabArgumentCompleters (PTAG) module works without it—I just skimmed the completions, they seem to be using the native Register-ArgumentCompleter function which should be compatible with core (also possibly TabExpansionPlusPlus, if you haven't tried it out yet)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants