SeeminglyScience / EditorServicesCommandSuite

Collection of editor commands for use in PowerShell Editor Services.
Other
152 stars 13 forks source link

Opening folder with PowerShell files tries to open a "Join-Path" file #36

Closed dprice closed 5 years ago

dprice commented 5 years ago

I am seeing a strange issue when opening (or re-opening) VSCode with PowerShell files. I get the Windows dialog:

image

If I choose Notepad, then it will open a non-existent file called "Join-Path":

image

I turned on Diagnostics logging level:

    "powershell.developer.editorServicesLogLevel": "Diagnostic"

My VSCode profile (C:\Users\derek.price\Documents\WindowsPowerShell\Microsoft.VSCode_profile.ps1) contains this:

Import-Module EditorServicesCommandSuite
Import-EditorCommand -Module EditorServicesCommandSuite

In EditorServices.log (attached) there's this on line 42 that may be the issue?

2019-01-10 13:30:55.075 [ERROR] tid:8 in 'InvokePowerShell' C:\PowerShellEditorServices\src\PowerShellEditorServices\Analysis\AnalysisService.cs: line 555
    The term 'Get-ScriptAnalyzerRule' 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.

Any ideas on how to fix this? It seems like it's related to this module. Thanks!

VSCodeLogs.zip

SeeminglyScience commented 5 years ago

@dprice Thanks for reporting this, that's definitely a new one! :)

Can you run these commands in the PowerShell Integrated Console (the one that starts up when you open a PowerShell document) and paste the output here?

Get-Module EditorServicesCommandSuite
Get-Command Join-Path -All
where.exe Join-Path
2019-01-10 13:30:55.075 [ERROR] tid:8 in 'InvokePowerShell' C:\PowerShellEditorServices\src\PowerShellEditorServices\Analysis\AnalysisService.cs: line 555
   The term 'Get-ScriptAnalyzerRule' 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.

Not sure that's related, but it's certainly unusual. PSScriptAnalyzer is bunded with the PowerShell extension, so unless it had a fatal exception while loading that shouldn't happen.

Can you check that this path exists?

$env:USERPROFILE\.vscode\extensions\ms-vscode.powershell-1.10.2\modules\PSScriptAnalyzer
dprice commented 5 years ago

Wow - fast reply! Here's the stuff you requested:

PS C:\dnx\dnx-dm-pureohs-importmanager\PowerShell> Get-Module EditorServicesCommandSuite

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     0.4.0      EditorServicesCommandSuite          {Add-CommandToManifest, Add-ModuleQualification, Add-PinvokeMethod, ConvertTo-FunctionDefinition...}

PS C:\dnx\dnx-dm-pureohs-importmanager\PowerShell> Get-Command Join-Path -All

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Join-Path                                          3.1.0.0    Microsoft.PowerShell.Management
Application     Join-Path                                          0.0.0.0    C:\Users\derek.price\Documents\WindowsPowerShell\Join-Path

PS C:\dnx\dnx-dm-pureohs-importmanager\PowerShell> where.exe Join-Path
C:\Users\derek.price\Documents\WindowsPowerShell\Join-Path

PS C:\dnx\dnx-dm-pureohs-importmanager\PowerShell> ls $env:USERPROFILE\.vscode\extensions\ms-vscode.powershell-1.10.2\modules\PSScriptAnalyzer

    Directory: C:\Users\derek.price\.vscode\extensions\ms-vscode.powershell-1.10.2\modules\PSScriptAnalyzer

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       12/21/2018   9:39 AM                1.17.1

I just noticed the zero-byte Join-Path in my Documents folder. I deleted it and that seems to have fixed it. I have no idea how that file would have been generated...

Now onto figuring out why i get "Cannot read property of 'onError' of undefined' when trying to run a script.

Thanks for the help!

SeeminglyScience commented 5 years ago

I just noticed the zero-byte Join-Path in my Documents folder. I deleted it and that seems to have fixed it. I have no idea how that file would have been generated...

Awesome! The most common way a file like that is generated is some from '' > Join-Path or New-Item Join-Path $etc. Easier to do without noticing than one would think 😁

Now onto figuring out why i get "Cannot read property of 'onError' of undefined' when trying to run a script.

Got live share installed?

dprice commented 5 years ago

That was the fix for my "onError" message - thanks again!