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

Errors with Import-Module WTToolbox #1

Closed
dprice opened this issue May 6, 2020 · 16 comments
Closed

Errors with Import-Module WTToolbox #1

dprice opened this issue May 6, 2020 · 16 comments
Assignees
Labels
bug Something isn't working pending feedback

Comments

@dprice
Copy link

dprice commented May 6, 2020

Good Morning!

I just installed WTToolbox via Install-Module WTToolBox -Scope CurrentUser. When I ran Import-Module WTToolbox, I got this error:

❯ Import-Module WTToolBox
Add-Member : Cannot bind argument to parameter 'InputObject' because it is null.
At C:\Users\34160\Documents\WindowsPowerShell\Modules\WTToolBox\1.1.0\functions\private.ps1:41 char:12
+     $obj | Add-Member -MemberType NoteProperty -Name Computername -Va ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCommand

Add-Member : Cannot bind argument to parameter 'InputObject' because it is null.
At C:\Users\34160\Documents\WindowsPowerShell\Modules\WTToolBox\1.1.0\functions\private.ps1:42 char:12
+     $obj | Add-Member -MemberType NoteProperty -Name LastUpdated -Val ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCommand

Add-Member : Cannot bind argument to parameter 'InputObject' because it is null.
At C:\Users\34160\Documents\WindowsPowerShell\Modules\WTToolBox\1.1.0\functions\private.ps1:43 char:12
+     $obj | Add-Member -MemberType NoteProperty -Name LastRefresh -Val ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCommand

Add-Member : Cannot bind argument to parameter 'InputObject' because it is null.
At C:\Users\34160\Documents\WindowsPowerShell\Modules\WTToolBox\1.1.0\functions\private.ps1:45 char:12
+     $obj | Add-Member -MemberType ScriptMethod -Name Refresh -Value { ...
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCommand

What can I do to help debug this for you?

Thanks,
Derek

@jdhitsolutions
Copy link
Owner

Is WindowsTerminal already installed? The module shouldn't be trying to create the variables if it isn't. I'm working on a new release so let me go back over this code. What version of PowerShell are you running on what operating system?

@jdhitsolutions jdhitsolutions added the bug Something isn't working label May 6, 2020
@jdhitsolutions jdhitsolutions self-assigned this May 6, 2020
@jdhitsolutions
Copy link
Owner

After importing the module, do you have $WTSettingsPath?

PS C:\> $WTSettingsPath
C:\Users\Jeff\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json

@jdhitsolutions
Copy link
Owner

Can you post your settings.json file?

@dprice
Copy link
Author

dprice commented May 6, 2020

I definitely have WT installed on my Windows 10 laptop and currently running. That previous error was for Windows PowerShell 5.1. I just tried in PowerShell 7 and got a very similar error:

❯ Import-Module WTToolBox
Add-Member: C:\Users\34160\Documents\WindowsPowerShell\Modules\WTToolBox\1.1.0\functions\private.ps1:41
Line |
  41 |      $obj | Add-Member -MemberType NoteProperty -Name Computername -Va …
     |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot bind argument to parameter 'InputObject' because it is null.

Add-Member: C:\Users\34160\Documents\WindowsPowerShell\Modules\WTToolBox\1.1.0\functions\private.ps1:42
Line |
  42 |      $obj | Add-Member -MemberType NoteProperty -Name LastUpdated -Val …
     |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot bind argument to parameter 'InputObject' because it is null.

Add-Member: C:\Users\34160\Documents\WindowsPowerShell\Modules\WTToolBox\1.1.0\functions\private.ps1:43
Line |
  43 |      $obj | Add-Member -MemberType NoteProperty -Name LastRefresh -Val …
     |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot bind argument to parameter 'InputObject' because it is null.

Add-Member: C:\Users\34160\Documents\WindowsPowerShell\Modules\WTToolBox\1.1.0\functions\private.ps1:45
Line |
  45 |      $obj | Add-Member -MemberType ScriptMethod -Name Refresh -Value { …
     |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Cannot bind argument to parameter 'InputObject' because it is null.

After installing and importing the above for v7, this is my path:

❯ $WTSettingsPath
C:\Users\34160\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json

My settings.json is attached as settings.json.txt since .json was not a supported file type:
settings.json.txt

@jdhitsolutions
Copy link
Owner

The attachment doesn't seem to be working. Can you run this command without getting an error?

(Get-Content -path $Global:WTSettingsPath).where({$_ -notmatch "//"}) | ConvertFrom-Json

I wonder if there is something I'm not taking into account with your settings file.

@dprice
Copy link
Author

dprice commented May 6, 2020

Runs fine:

❯ (Get-Content -path $Global:WTSettingsPath).where({$_ -notmatch "//"}) | ConvertFrom-Json

defaultProfile              : {574e775e-4f2a-5b96-ac1e-a2962a402336}
showTabsInTitlebar          : True
showTerminalTitleInTitlebar : True
wordDelimiters              :  ./\()"'-:,.;<>~!@#$%^&*|+=[]{}~?
copyOnSelect                : True
snapToGridOnResize          : True
profiles                    : @{defaults=; list=System.Object[]}
schemes                     : {@{name=Material; background=#1E282C; black=#073641; blue=#80CBC3; brightBlack=#002B36; brightBlue=#7DC6BF; brightCyan=#34434D; brightGreen=#C3E88D; brightPurple=#6C71C3; brightRed=#EB606B; brightW
                              hite=#FFFFFF; brightYellow=#F7EB95; cyan=#AEDDFF; foreground=#C3C7D1; green=#C3E88D; purple=#FF2490; red=#EB606B; white=#FFFFFF; yellow=#F7EB95}, @{name=Dracula; background=#282A36; black=#21222C;
                              blue=#BD93F9; brightBlack=#6272A4; brightBlue=#D6ACFF; brightCyan=#A4FFFF; brightGreen=#69FF94; brightPurple=#FF92DF; brightRed=#FF6E6E; brightWhite=#FFFFFF; brightYellow=#FFFFA5; cyan=#8BE9FD; for
                              eground=#F8F8F2; green=#50FA7B; purple=#FF79C6; red=#FF5555; white=#F8F8F2; yellow=#F1FA8C}, @{name=Cobalt2; black=#000000; red=#ff0000; green=#38de21; yellow=#ffe50a; blue=#1460d2; purple=#ff005d;
                               cyan=#00bbbb; white=#bbbbbb; brightBlack=#555555; brightRed=#f40e17; brightGreen=#3bd01d; brightYellow=#edc809; brightBlue=#5555ff; brightPurple=#ff55ff; brightCyan=#6ae3fa; brightWhite=#ffffff; b
                              ackground=#132738; foreground=#ffffff}, @{name=SeaShells; black=#17384c; red=#d15123; green=#027c9b; yellow=#fca02f; blue=#1e4950; purple=#68d4f1; cyan=#50a3b5; white=#deb88d; brightBlack=#434b53;
                              brightRed=#d48678; brightGreen=#628d98; brightYellow=#fdd39f; brightBlue=#1bbcdd; brightPurple=#bbe3ee; brightCyan=#87acb4; brightWhite=#fee4ce; background=#09141b; foreground=#deb88d}…}
keybindings                 : {@{command=closeTab; keys=System.Object[]}, @{command=newTab; keys=System.Object[]}}

@jdhitsolutions
Copy link
Owner

I'm testing with a virgin test system and I'm getting the same errors you are. Digging.

@jdhitsolutions
Copy link
Owner

Not sure why Add-Member is misbehaving. But I'm modifying syntax that should solve this problem. Let me finish up v1.1.0 and I'll let you know when it is published.

@dprice
Copy link
Author

dprice commented May 6, 2020

Great - thanks!

@jdhitsolutions
Copy link
Owner

Update the module to 1.2.0 and this should solve the problem.

@dprice
Copy link
Author

dprice commented May 6, 2020

What's the best way? Update-Module WTToolBox? Install-Module WTToolBox -Scope CurrentUser -Force?

@jdhitsolutions
Copy link
Owner

If you've already installed it using Install-Module, then you can update it Update-Module WTToolbox.

@dprice
Copy link
Author

dprice commented May 6, 2020

Can win today... I tried and got this 🤦‍♂️
I definitely updated with Install-Module

❯ Update-Module WTToolBox
Update-Module: Module 'WTToolBox' was not installed by using Install-Module, so it cannot be updated.

@jdhitsolutions
Copy link
Owner

I can't recall if you are using Windows PowerShell or PowerShell 7. You need to run the update module in the same version of PowerShell where you installed it. It might be just as easy to uninstall it.

``powershell
Get-module WTToolbox -list | uninstall-module

@dprice
Copy link
Author

dprice commented May 7, 2020

That failed, of course, but I just a force install and it's working now.

@dprice dprice closed this as completed May 7, 2020
@dprice
Copy link
Author

dprice commented May 7, 2020

Forgot to close the issue - thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending feedback
Projects
None yet
Development

No branches or pull requests

2 participants