Vscode-powershell: Unable to start debugging interactive session

Created on 6 Jan 2020  路  7Comments  路  Source: PowerShell/vscode-powershell

Issue Description

I am experiencing a problem with launching a powershell debugging session.

When launching a debug session, the powershell session crashes with this error (found it in the event viewer)

Error Message = The process cannot access the file 'c:\Users\avezina\.vscode\extensions\ms-vscode.powershell-preview-2019.12.0\logs\1578329950-8940193b-522e-41b2-b5f5-c1fce8b387181578329944994\StartEditorServices.log' because it is being used by another process.
Fully Qualified Error ID = System.IO.IOException,Microsoft.PowerShell.EditorServices.Commands.StartEditorServicesCommand

2020-01-06_13-27-02

Attached Logs

EditorServices.log
StartEditorServices.log
vscode-powershell.log
EditorServiceOutput.txt

Environment Information

Visual Studio Code

| Name | Version |
| --- | --- |
| Operating System | Windows_NT x64 10.0.18362 |
| VSCode | 1.41.1|
| PowerShell Extension Version | 2019.12.0 |

PowerShell Information

|Name|Value|
|---|---|
|PSVersion|5.1.18362.145|
|PSEdition|Desktop|
|PSCompatibleVersions|1.0 2.0 3.0 4.0 5.0 5.1.18362.145|
|BuildVersion|10.0.18362.145|
|CLRVersion|4.0.30319.42000|
|WSManStackVersion|3.0|
|PSRemotingProtocolVersion|2.3|
|SerializationVersion|1.1.0.1|

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)

|Extension|Author|Version|
|---|---|---|
|azure-account|ms-vscode|0.8.7|
|azure-pipelines|ms-azure-devops|1.157.4|
|better-align|wwm|1.1.6|
|Bookmarks|alefragnani|10.6.0|
|bracket-pair-colorizer|CoenraadS|1.0.61|
|code-settings-sync|Shan|3.4.3|
|cpptools|ms-vscode|0.26.2|
|git-extension-pack|donjayamanne|0.1.3|
|githistory|donjayamanne|0.4.13|
|gitignore|codezombiech|0.6.0|
|gitlens|eamodio|10.2.0|
|LiveServer|ritwickdey|5.6.1|
|markdown-all-in-one|yzhang|2.6.1|
|material-icon-theme|PKief|3.9.2|
|material-theme|zhuangtongfa|3.2.1|
|one-monokai|azemoh|0.4.6|
|powershell-preview|ms-vscode|2019.12.0|
|project-manager|alefragnani|10.9.1|
|team|ms-vsts|1.161.0|
|Theme-MaterialKit|ms-vscode|0.1.4|
|theme-monokai-pro-vscode|monokai|1.1.14|
|theme-onedark|azemoh|0.5.3|
|Theme-TomorrowKit|ms-vscode|0.1.4|
|timing|HaaLeo|2.3.0|
|vscode-azurefunctions|ms-azuretools|0.20.1|
|vscode-icons|vscode-icons-team|9.7.0|
|vscode-markdownlint|DavidAnson|0.33.0|
|vscode-mscgen|mscgenjs|1.2.0|
|vscode-open-in-github|ziyasal|1.3.6|
|vscode-sanddance|msrvida|1.2.12|
|vscode-simple-icons|LaurentTreguier|1.11.11|
|vscode-todo-highlight|wayou|1.0.4|
|vsliveshare|ms-vsliveshare|1.0.1404|

Area-Logging Issue-Bug

All 7 comments

More details from the Event Viewer :

Error Message = The process cannot access the file 'c:\Users\avezina\.vscode\extensions\ms-vscode.powershell-preview-2019.12.0\logs\1578336632-6fb57ae5-725f-4c81-b9b3-09aae0695d471578336628071\StartEditorServices.log' because it is being used by another process.
Fully Qualified Error ID = System.IO.IOException,Microsoft.PowerShell.EditorServices.Commands.StartEditorServicesCommand


Context:
        Severity = Warning
        Host Name = ConsoleHost
        Host Version = 5.1.18362.145
        Host ID = 1cc97081-d9fc-4111-8306-fedcd004d528
        Host Application = C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -Command Import-Module 'c:\Users\avezina\.vscode\extensions\ms-vscode.powershell-preview-2019.12.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2019.12.0' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\avezina\.vscode\extensions\ms-vscode.powershell-preview-2019.12.0\modules' -EnableConsoleRepl -LogLevel 'Diagnostic' -DebugServiceOnly -LogPath 'c:\Users\avezina\.vscode\extensions\ms-vscode.powershell-preview-2019.12.0\logs\1578336632-6fb57ae5-725f-4c81-b9b3-09aae0695d471578336628071\DebugSession-1.log' -SessionDetailsPath 'c:\Users\avezina\.vscode\extensions\ms-vscode.powershell-preview-2019.12.0\sessions\PSES-VSCode-17704-Debug' -FeatureFlags @() 
        Engine Version = 5.1.18362.145
        Runspace ID = f3293bce-19b8-4ab8-ba3a-ce164e122399
        Pipeline ID = 1
        Command Name = Start-EditorServices
        Command Type = Cmdlet
        Script Name = 
        Command Path = 
        Sequence Number = 15
        User = [REDACTED]\avezina
        Connected User = 
        Shell ID = Microsoft.PowerShell


User Data:

Ok let me have a play with this this week. I know where it's occurring, so hopefully it's not too hard to work out why and how to fix it.

Screenshot of the error in the terminal:

output-onlineimagetools

Working through this (easily reproduced), I've fixed the initial issue but immediately hit another:

Exception encountered starting EditorServices. Exception logged in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices.Hosting\Commands\StartEditorServicesCommand.cs on line 227 in EndProcessing:
System.AggregateException: One or more errors occurred. (Unable to resolve service for type 'OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServer' while attempting to activate 'Microsoft.PowerShell.EditorServices.Services.EditorOperationsService'.)
 ---> System.InvalidOperationException: Unable to resolve service for type 'OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServer' while attempting to activate 
'Microsoft.PowerShell.EditorServices.Services.EditorOperationsService'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.<>c__DisplayClass7_0.<GetCallSite>b__0(Type type)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.<>c__DisplayClass7_0.<GetCallSite>b__0(Type type)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.CreateServiceAccessor(Type serviceType)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)        
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at Microsoft.PowerShell.EditorServices.Server.PsesServiceCollectionExtensions.AddPsesDebugServices(IServiceCollection collection, IServiceProvider languageServiceProvider, PsesDebugServer psesDebugServer, Boolean useTempSession) in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices\Server\PsesServiceCollectionExtensions.cs:line 62
   at Microsoft.PowerShell.EditorServices.Server.PsesDebugServer.<StartAsync>b__13_0(JsonRpcServerOptions options) in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices\Server\PsesDebugServer.cs:line 83
   at OmniSharp.Extensions.JsonRpc.JsonRpcServer.From(Action`1 optionsAction)
   at Microsoft.PowerShell.EditorServices.Server.PsesDebugServer.StartAsync() in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices\Server\PsesDebugServer.cs:line 62
   at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesRunner.RunTempDebugSessionAsync(HostStartupInfo hostDetails) in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices.Hosting\Internal\EditorServicesRunner.cs:line 139
   at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesRunner.CreateEditorServicesAndRunUntilShutdown() in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices.Hosting\Internal\EditorServicesRunner.cs:line 86
   at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesRunner.RunUntilShutdown() in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices.Hosting\Internal\EditorServicesRunner.cs:line 60
   at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesLoader.LoadAndRunEditorServicesAsync() in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices.Hosting\EditorServicesLoader.cs:line 192
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at Microsoft.PowerShell.EditorServices.Commands.StartEditorServicesCommand.EndProcessing() in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices.Hosting\Commands\StartEditorServicesCommand.cs:line 222
Exception encountered starting EditorServices. Exception logged in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices.Hosting\Commands\StartEditorServicesCommand.cs on line 227 in EndProcessing:
System.AggregateException: One or more errors occurred. (Unable to resolve service for type 'OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServer' while attempting to activate 'Microsoft.PowerShell.EditorServices.Services.EditorOperationsService'.)
 ---> System.InvalidOperationException: Unable to resolve service for type 'OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServer' while attempting to activate 
'Microsoft.PowerShell.EditorServices.Services.EditorOperationsService'.
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.<>c__DisplayClass7_0.<GetCallSite>b__0(Type type)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, Boolean throwIfCallSiteNotFound)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(ResultCache lifetime, Type serviceType, Type implementationType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(ServiceDescriptor descriptor, Type serviceType, CallSiteChain callSiteChain, Int32 slot)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateCallSite(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.<>c__DisplayClass7_0.<GetCallSite>b__0(Type type)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Type serviceType, CallSiteChain callSiteChain)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.CreateServiceAccessor(Type serviceType)
   at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)        
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
   at Microsoft.PowerShell.EditorServices.Server.PsesServiceCollectionExtensions.AddPsesDebugServices(IServiceCollection collection, IServiceProvider languageServiceProvider, PsesDebugServer psesDebugServer, Boolean useTempSession) in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices\Server\PsesServiceCollectionExtensions.cs:line 62
   at Microsoft.PowerShell.EditorServices.Server.PsesDebugServer.<StartAsync>b__13_0(JsonRpcServerOptions options) in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices\Server\PsesDebugServer.cs:line 83
   at OmniSharp.Extensions.JsonRpc.JsonRpcServer.From(Action`1 optionsAction)
   at Microsoft.PowerShell.EditorServices.Server.PsesDebugServer.StartAsync() in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices\Server\PsesDebugServer.cs:line 62
   at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesRunner.RunTempDebugSessionAsync(HostStartupInfo hostDetails) in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices.Hosting\Internal\EditorServicesRunner.cs:line 139
   at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesRunner.CreateEditorServicesAndRunUntilShutdown() in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices.Hosting\Internal\EditorServicesRunner.cs:line 86
   at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesRunner.RunUntilShutdown() in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices.Hosting\Internal\EditorServicesRunner.cs:line 60
   at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesLoader.LoadAndRunEditorServicesAsync() in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices.Hosting\EditorServicesLoader.cs:line 192
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at Microsoft.PowerShell.EditorServices.Commands.StartEditorServicesCommand.EndProcessing() in C:\Users\roholt\Documents\Dev\PowerShellEditorServices\src\PowerShellEditorServices.Hosting\Commands\StartEditorServicesCommand.cs:line 222

Looking over this, in the temp debugging scenario we don't create a language server on the basis that one isn't needed. However, the debugger requires the WorkspaceService, which requires the EditorOperationsService, which requires the language server.

Since creating a language server requires some configuration and networking, I'm not sure if just adding one will be the easiest fix. So I might invesigate with @TylerLeonhardt and see what the best solution is.

I've got a fix out for this one.

is it already fixed? Do I need to do something else than updating the extension?

is it already fixed? Do I need to do something else than updating the extension?

It won't be available until the next release, which we're currently planning to do before the end of the month

Was this page helpful?
0 / 5 - 0 ratings