Closed danielfeiler closed 5 years ago
Relevant log info:
2019-06-04 09:20:39.575 [ERROR] tid:16 in 'Create' C:\PowerShellEditorServices\src\PowerShellEditorServices\Analysis\AnalysisService.cs: line 200
Exception: PSScriptAnalyzer cannot be imported, AnalysisService will be disabled
Microsoft.PowerShell.EditorServices.AnalysisServiceLoadException: PSScriptAnalyzer runspace pool could not be created ---> Microsoft.PowerShell.EditorServices.AnalysisServiceLoadException: Unable to find PSScriptAnalyzer module on the module path
at Microsoft.PowerShell.EditorServices.AnalysisService.CreatePssaRunspacePool(PSModuleInfo& pssaModuleInfo)
at Microsoft.PowerShell.EditorServices.AnalysisService.Create(String settingsPath, ILogger logger)
--- End of inner exception stack trace ---
at Microsoft.PowerShell.EditorServices.AnalysisService.Create(String settingsPath, ILogger logger)
2019-06-04 09:20:41.961 [NORMAL] tid:10 in 'Register' C:\PowerShellEditorServices\src\PowerShellEditorServices.VSCode\ComponentRegistration.cs: line 36
PowerShell Editor Services VS Code module loaded.
2019-06-04 09:21:07.691 [ERROR] tid:46 in 'OnListenTaskCompleted' C:\PowerShellEditorServices\src\PowerShellEditorServices.Protocol\MessageProtocol\ProtocolEndpoint.cs: line 391
ProtocolEndpoint message loop terminated due to unhandled exception:
System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.<Format>d__66.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.<HandleDocumentRangeFormattingRequest>d__62.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.<Format>d__66.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.PowerShell.EditorServices.Protocol.Server.LanguageServer.<HandleDocumentRangeFormattingRequest>d__62.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.MessageDispatcher.<DispatchMessage>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerShell.EditorServices.Protocol.MessageProtocol.ProtocolEndpoint.<ListenForMessages>d__36.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.PowerShell.EditorServices.Utility.AsyncContext.Start(Func`1 asyncMainFunc, ILogger logger)
at System.Threading.Tasks.Task.Execute()<---
Looks like PSSA can't be loaded (which is strange since it's bundled with the extension) and then we don't handle the load failure properly
@danielfeiler Can you report the output of the following in the Integrated Console:
Import-Module PSScriptAnalyzer
@rjmholt of course:
PowerShell Integrated Console
PS C:\Users\danielfeiler> Import-Module PSScriptAnalyzer
Import-Module : The specified module 'PSScriptAnalyzer' was not loaded because no valid module file was found in any module
directory.
At line:1 char:1
+ Import-Module PSScriptAnalyzer
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (PSScriptAnalyzer:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
PS C:\Users\danielfeiler>
Hmmmm, that's very odd.
Have you altered $env:PSModulePath
maybe?
Can you tell me what the following output:
gmo -list PSScriptAnalyzer
gci ~\.vscode\extensions\ms-vscode.powershell-2019.5.0\modules
$env:PSModulePath
Also you should be able to fix this immediately with Install-Module PSScriptAnalyzer -Scope CurrentUser
@danielfeiler were you able to resolve this issue with @rjmholt 's suggestion above?
Going to go ahead and close this as resolved but will re-open if you are still facing this issue--Thanks!
If I try to do teh action "Format Document on a Windows 2008 R2 machine I get the message "The PowerShell session has terminated due to an error, would you like to restart it? Extension logfile is attached. EditorServices.log