vscode-powershell icon indicating copy to clipboard operation
vscode-powershell copied to clipboard

PowerShell extension fails to start inside container

Open pcgeek86 opened this issue 2 years ago • 2 comments

Prerequisites

  • [X] I have written a descriptive issue title.
  • [X] I have searched all issues to ensure it has not already been reported.
  • [X] I have read the troubleshooting guide.
  • [X] I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.

Summary

When attaching VSCode to a container, using the Remote - Containers extension, an exception is thrown in the logs, and the extension fails to startup. I'm using Docker Desktop to spin up a PowerShell 7.1.3 container "locally," and then attempting to attach to it.

PowerShell Version

PowerShell 7.1.3
Copyright (c) Microsoft Corporation.

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

PS /> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Linux 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visual Studio Code Version

1.58.2
c3f126316369cd610563c75b1b1725e0679adfb3
x64

Extension Version

[email protected]

Steps to Reproduce

  1. Run a new PowerShell container with Docker Desktop docker run --rm --interactive --tty mcr.microsoft.com/powershell
  2. Connect VSCode to container using Attach to Running Container command
  3. Create a new PowerShell script file
  4. Observe how extension fails to load. Starting PowerShell... text stays active in lower-right corner of VSCode window.

Visuals

image

Logs

[Warn  - 2:57:53 PM] OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OutgoingNotification { Method = powerShell/executionStatusChanged, Params = Microsoft.PowerShell.EditorServices.Services.PowerShellContext.ExecutionStatusChangedEventArgs, TraceParent = , TraceState =  } | @Request='OutgoingNotification { Method = powerShell/executionStatusChanged, Params = Microsoft.PowerShell.EditorServices.Services.PowerShellContext.ExecutionStatusChangedEventArgs, TraceParent = , TraceState =  }'
[Warn  - 2:57:53 PM] OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OutgoingNotification { Method = powerShell/executionStatusChanged, Params = Microsoft.PowerShell.EditorServices.Services.PowerShellContext.ExecutionStatusChangedEventArgs, TraceParent = , TraceState =  } | @Request='OutgoingNotification { Method = powerShell/executionStatusChanged, Params = Microsoft.PowerShell.EditorServices.Services.PowerShellContext.ExecutionStatusChangedEventArgs, TraceParent = , TraceState =  }'
[Warn  - 2:57:53 PM] OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OutgoingNotification { Method = powerShell/executionStatusChanged, Params = Microsoft.PowerShell.EditorServices.Services.PowerShellContext.ExecutionStatusChangedEventArgs, TraceParent = , TraceState =  } | @Request='OutgoingNotification { Method = powerShell/executionStatusChanged, Params = Microsoft.PowerShell.EditorServices.Services.PowerShellContext.ExecutionStatusChangedEventArgs, TraceParent = , TraceState =  }'
[Warn  - 2:57:53 PM] OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OutgoingNotification { Method = powerShell/executionStatusChanged, Params = Microsoft.PowerShell.EditorServices.Services.PowerShellContext.ExecutionStatusChangedEventArgs, TraceParent = , TraceState =  } | @Request='OutgoingNotification { Method = powerShell/executionStatusChanged, Params = Microsoft.PowerShell.EditorServices.Services.PowerShellContext.ExecutionStatusChangedEventArgs, TraceParent = , TraceState =  }'
[Warn  - 2:57:53 PM] OmniSharp.Extensions.LanguageServer.Server.LspServerOutputFilter: Tried to send request or notification before initialization was completed and will be sent later OmniSharp.Extensions.JsonRpc.Server.Messages.InternalError | @Request='OmniSharp.Extensions.JsonRpc.Server.Messages.InternalError'
[Error - 2:57:53 PM] OmniSharp.Extensions.JsonRpc.InputHandler: Unknown error handling request - Newtonsoft.Json.JsonSerializationException: Error setting value to 'RootPath' on 'OmniSharp.Extensions.LanguageServer.Protocol.Models.InternalInitializeParams'.
 ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.String.get_Chars(Int32 index)
   at OmniSharp.Extensions.LanguageServer.Protocol.DocumentUri.File(String path)
   at lambda_method99(Closure , Object , Object )
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.SetValue(Object target, Object value)
   --- End of inner exception stack trace ---
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.SetValue(Object target, Object value)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonConverter propertyConverter, JsonContainerContract containerContract, JsonProperty containerProperty, JsonReader reader, Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, JsonProperty member, String id)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.Linq.JToken.ToObject(Type objectType, JsonSerializer jsonSerializer)
   at OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter.FindDescriptor(String method, JToken params)
   at OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter.FindDescriptor(IMethodWithParams instance)
   at OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter.GetDescriptors(Request request)
   at OmniSharp.Extensions.LanguageServer.Shared.LspRequestRouter.OmniSharp.Extensions.JsonRpc.IRequestRouter<OmniSharp.Extensions.JsonRpc.IHandlerDescriptor>.GetDescriptors(Request request)
   at OmniSharp.Extensions.JsonRpc.InputHandler.HandleRequest(ReadOnlySequence`1& request) | 

pcgeek86 avatar Jul 19 '21 15:07 pcgeek86

That looks like a pretty clear cut bug! I'll try to reproduce. Thanks for the report.

andyleejordan avatar Jul 19 '21 17:07 andyleejordan

This will probably be fixed when we finish https://github.com/PowerShell/vscode-powershell/pull/3796 to fix https://github.com/PowerShell/vscode-powershell/issues/2153 and stop using the deprecated field rootPath.

andyleejordan avatar Feb 28 '22 20:02 andyleejordan

This reproed for me today

[Error - 6:48:27 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 6:48:27 PM] Connection to PowerShell Editor Services (the Extension Terminal) was closed. See below prompt to restart!
[Error - 6:48:27 PM] PowerShell Editor Services client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 

SydneyhSmith avatar Mar 13 '23 18:03 SydneyhSmith

@SydneyhSmith do you have any more detailed logs? Would love to know what the server said.

andyleejordan avatar Mar 13 '23 19:03 andyleejordan

Retested and got it running no problem 😄 -- looks resolved to me

SydneyhSmith avatar Mar 13 '23 19:03 SydneyhSmith

Hurray!

andyleejordan avatar Mar 13 '23 22:03 andyleejordan

This issue has been marked as fixed. It has been automatically closed for housekeeping purposes.

ghost avatar Mar 14 '23 01:03 ghost