Skip to content

Fail Starting Powershell - VS Code #3827

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

Closed
5 tasks done
itconsultingnc opened this issue Feb 13, 2022 · 35 comments
Closed
5 tasks done

Fail Starting Powershell - VS Code #3827

itconsultingnc opened this issue Feb 13, 2022 · 35 comments
Labels
Issue-Bug A bug to squash.

Comments

@itconsultingnc
Copy link

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.

Summary

Hi,
When opening Visual Studio Code, powershell try to start, but failed.
With this error

Exception encountered starting EditorServices. Exception logged in D:\a\1\s\src\PowerShellEditorServices.Hosting\Commands\StartEditorServicesCommand.cs on line 246 in EndProcessing:
System.AggregateException: An error occurred while writing to logger(s). ---> DryIoc.ContainerException: code: Error.WaitForScopedServiceIsCreatedTimeoutExpired;
message: DryIoc has waited for the creation of the scoped or singleton service by the "other party" for the  ticks without the completion. 
You may call `exception.TryGetDetails(container)` to get the details of the problematic service registration.
The error means that either the "other party" is the parallel thread which has started but is unable to finish the creation of the service in the provided amount of time. 
Or more likely the "other party"  is the same thread and there is an undetected recursive dependency or 
the scoped service creation is failed with the exception and the exception was catched but you are trying to resolve the failed service again. 
For all those reasons DryIoc has a timeout to prevent the infinite waiting. 
You may change the default timeout via `Scope.WaitForScopedServiceIsCreatedTimeoutTicks=NewNumberOfTicks`
   à DryIoc.ContainerException.WithDetails(Object details, Int32 error, Object arg0, Object arg1, Object arg2, Object arg3)
   à DryIoc.Scope.WaitForItemIsSet(ImMapEntry`1 itemRef)
   à DryIoc.Factory.GetExpressionOrDefault(Request request)
   à DryIoc.Container.ResolveAndCacheKeyed(Int32 serviceTypeHash, Type serviceType, Object serviceKey, IfUnresolved ifUnresolved, Object scopeName, Type requiredServiceType, Request preResolveParent, Object[] args)
   à DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, Object serviceKey, IfUnresolved ifUnresolved, Type requiredServiceType, Request preResolveParent, Object[] args)
   à DryIoc.Interpreter.InterpretResolveMethod(IResolverContext resolver, IList`1 callArgs, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec, Object& result)
   à DryIoc.Interpreter.TryInterpretMethodCall(IResolverContext r, Expression expr, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec, Object& result)
   à DryIoc.Interpreter.TryInterpret(IResolverContext r, Expression expr, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec, Object& result)
   à DryIoc.Interpreter.TryInterpretNestedLambdaBodyAndUnwrapException(IResolverContext r, Expression bodyExpr, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec)      
   à DryIoc.Interpreter.<>c__DisplayClass3_0.<TryInterpretNestedLambda>b__0()
   à DryIoc.Interpreter.<>c__DisplayClass5_0`1.<ConvertFunc>b__0()
   à System.Lazy`1.CreateValue()
   à System.Lazy`1.LazyInitValue()
   à OmniSharp.Extensions.JsonRpc.ResponseRouter.SendNotification[T](String method, T params)
   à OmniSharp.Extensions.LanguageServer.Server.Logging.LanguageServerLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
   à Microsoft.Extensions.Logging.Logger.<Log>g__LoggerLog|12_0[TState](LogLevel logLevel, EventId eventId, ILogger logger, Exception exception, Func`3 formatter, List`1& exceptions, TState& state)    
   --- Fin de la trace de la pile d'exception interne ---
   à Microsoft.Extensions.Logging.Logger.ThrowLoggingError(List`1 exceptions)
   à Microsoft.Extensions.Logging.Logger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
   à Microsoft.Extensions.Logging.Logger`1.Microsoft.Extensions.Logging.ILogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
   à Microsoft.Extensions.Logging.LoggerExtensions.Log(ILogger logger, LogLevel logLevel, EventId eventId, Exception exception, String message, Object[] args)
   à OmniSharp.Extensions.JsonRpc.OutputHandler.<.ctor>b__13_3(Exception e)
   à System.Reactive.Linq.ObservableImpl.Do`1.Actions._.OnError(Exception error)
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Reactive.Stubs.<>c.<.cctor>b__2_1(Exception ex)
   à System.Reactive.AnonymousSafeObserver`1.OnError(Exception error)
   à System.Reactive.Sink`1.ForwardOnError(Exception error)
   à System.Reactive.Linq.ObservableImpl.Do`1.Actions._.OnError(Exception error)
   à System.Reactive.Sink`2.OnError(Exception error)
   à System.Reactive.Linq.ObservableImpl.ThrowImmediate`1.Run(IObserver`1 observer)
   à System.Reactive.BasicProducer`1.SubscribeRaw(IObserver`1 observer, Boolean enableSafeguard)
   à System.Reactive.Linq.ObservableImpl.Defer`1._.Run()
   à System.Reactive.Producer`2.SubscribeRaw(IObserver`1 observer, Boolean enableSafeguard)
   à System.Reactive.Linq.ObservableImpl.Do`1.Actions.Run(_ sink)
   à System.Reactive.Concurrency.Scheduler.<>c__75`1.<ScheduleAction>b__75_0(IScheduler _, ValueTuple`2 tuple)
   à System.Reactive.Concurrency.CurrentThreadScheduler.Schedule[TState](TState state, TimeSpan dueTime, Func`3 action)
   à System.Reactive.Concurrency.LocalScheduler.Schedule[TState](TState state, Func`3 action)
   à System.Reactive.Concurrency.Scheduler.ScheduleAction[TState](IScheduler scheduler, TState state, Action`1 action)
   à System.Reactive.Producer`2.SubscribeRaw(IObserver`1 observer, Boolean enableSafeguard)
   à OmniSharp.Extensions.JsonRpc.OutputHandler..ctor(PipeWriter pipeWriter, ISerializer serializer, IEnumerable`1 outputFilters, IScheduler scheduler, ILogger`1 logger, IActivityTracingStrategy activityTracingStrategy)
   à DryIoc.Interpreter.TryInterpretAndUnwrapContainerException(IResolverContext r, Expression expr, Boolean useFec, Object& result)
   à DryIoc.Factory.ApplyReuse(Expression serviceExpr, Request request)
   à DryIoc.Factory.GetExpressionOrDefault(Request request)
   à DryIoc.FactoryMethod.<>c__DisplayClass10_0.<Constructor>b__0(Request request)
   à DryIoc.ReflectionFactory.CreateExpressionOrDefault(Request request)
   à DryIoc.Factory.GetExpressionOrDefault(Request request)
   à DryIoc.ReflectionFactory.CreateExpressionOrDefault(Request request)
   à DryIoc.Factory.GetExpressionOrDefault(Request request)
   à DryIoc.Container.ResolveAndCache(Int32 serviceTypeHash, Type serviceType, IfUnresolved ifUnresolved)
   à DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, IfUnresolved ifUnresolved)
   à DryIoc.Resolver.Resolve[TService](IResolver resolver, IfUnresolved ifUnresolved)
   à OmniSharp.Extensions.LanguageServer.Server.LanguageServer.<From>d__37.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   à Microsoft.PowerShell.EditorServices.Server.PsesLanguageServer.<StartAsync>d__14.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   à Microsoft.PowerShell.EditorServices.Hosting.EditorServicesRunner.<CreateEditorServicesAndRunUntilShutdown>d__9.MoveNext()
--- Fin de la trace de la pile à partir de l'emplacement précédent au niveau duquel l'exception a été levée ---
   à System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   à System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   à Microsoft.PowerShell.EditorServices.Commands.StartEditorServicesCommand.EndProcessing()
---> (Exception interne #0) DryIoc.ContainerException: code: Error.WaitForScopedServiceIsCreatedTimeoutExpired;
message: DryIoc has waited for the creation of the scoped or singleton service by the "other party" for the  ticks without the completion.
You may call `exception.TryGetDetails(container)` to get the details of the problematic service registration.
The error means that either the "other party" is the parallel thread which has started but is unable to finish the creation of the service in the provided amount of time.
Or more likely the "other party"  is the same thread and there is an undetected recursive dependency or
the scoped service creation is failed with the exception and the exception was catched but you are trying to resolve the failed service again.
For all those reasons DryIoc has a timeout to prevent the infinite waiting.
You may change the default timeout via `Scope.WaitForScopedServiceIsCreatedTimeoutTicks=NewNumberOfTicks`
   à DryIoc.ContainerException.WithDetails(Object details, Int32 error, Object arg0, Object arg1, Object arg2, Object arg3)
   à DryIoc.Scope.WaitForItemIsSet(ImMapEntry`1 itemRef)
   à DryIoc.Factory.GetExpressionOrDefault(Request request)
   à DryIoc.Container.ResolveAndCacheKeyed(Int32 serviceTypeHash, Type serviceType, Object serviceKey, IfUnresolved ifUnresolved, Object scopeName, Type requiredServiceType, Request preResolveParent, Object[] args)
   à DryIoc.Container.DryIoc.IResolver.Resolve(Type serviceType, Object serviceKey, IfUnresolved ifUnresolved, Type requiredServiceType, Request preResolveParent, Object[] args)
   à DryIoc.Interpreter.InterpretResolveMethod(IResolverContext resolver, IList`1 callArgs, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec, Object& result)
   à DryIoc.Interpreter.TryInterpretMethodCall(IResolverContext r, Expression expr, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec, Object& result)
   à DryIoc.Interpreter.TryInterpret(IResolverContext r, Expression expr, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec, Object& result)
   à DryIoc.Interpreter.TryInterpretNestedLambdaBodyAndUnwrapException(IResolverContext r, Expression bodyExpr, Object paramExprs, Object paramValues, ParentLambdaArgs parentArgs, Boolean useFec)      
   à DryIoc.Interpreter.<>c__DisplayClass3_0.<TryInterpretNestedLambda>b__0()
   à DryIoc.Interpreter.<>c__DisplayClass5_0`1.<ConvertFunc>b__0()
   à System.Lazy`1.CreateValue()
   à System.Lazy`1.LazyInitValue()
   à OmniSharp.Extensions.JsonRpc.ResponseRouter.SendNotification[T](String method, T params)
   à OmniSharp.Extensions.LanguageServer.Server.Logging.LanguageServerLogger.Log[TState](LogLevel logLevel, EventId eventId, TState state, Exception exception, Func`3 formatter)
   à Microsoft.Extensions.Logging.Logger.<Log>g__LoggerLog|12_0[TState](LogLevel logLevel, EventId eventId, ILogger logger, Exception exception, Func`3 formatter, List`1& exceptions, TState& state)<---

Try with version of powershell extension :
PowerShell Integrated Console v2021.12.0
and
PowerShell Preview Integrated Console v2022.2.0

Same problem.
A few day ago, everything was working well, I don't know if some update occur, but right now it's not working anymore.

Windows 10 Entreprise x64 10.0.19044

PowerShell Version

Unable to entere this commande in Visual Code due to issue.
But i am using Powershell 7 and 5.1, same problem.

Visual Studio Code Version

VS code version : 1.64.2
64 bit

Extension Version

Steps to Reproduce

open Visual studio code
try to start Powershell
powershell

Visuals

No response

Logs

EditorServices.log :


2022-02-14 10:27:43.356 +11:00 [FTL] unhandled exception
System.MissingMethodException: Méthode introuvable : 'System.Threading.Tasks.ValueTask`1<!0> System.Threading.Channels.ChannelReader`1.ReadAsync(System.Threading.CancellationToken)'.
   à OmniSharp.Extensions.JsonRpc.OutputHandler.<ProcessOutputStream>d__19.MoveNext()
   à System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
   à OmniSharp.Extensions.JsonRpc.OutputHandler.ProcessOutputStream(CancellationToken cancellationToken)
   à System.Reactive.Linq.QueryLanguage.StartAsyncImpl(Func`1 actionAsync, IScheduler scheduler)

@itconsultingnc itconsultingnc added the Issue-Bug A bug to squash. label Feb 13, 2022
@ghost ghost added the Needs: Triage Maintainer attention needed! label Feb 13, 2022
@JustinGrote
Copy link
Collaborator

@itconsultingnc it looks like you have both the stable and preview extensions installed simultaneously, can you try running preview extension only?

@JustinGrote JustinGrote added Needs: Author Feedback Please give us the requested feedback! and removed Needs: Triage Maintainer attention needed! labels Feb 14, 2022
@itconsultingnc
Copy link
Author

Hi ,
I have tested uninstall the preview one, restarting vs code => Same error
then, have tested uninstall Powershell 2021.12.0 and reinstalled the preview one, restarting s code = > same error
Uninstalled both version, restart vs code, reinstall Powershell 2021.12.0 , restart vs code => same error.
ISE is working well, whatever powershell version is installed.

thank you for your advise.

@ghost ghost added Needs: Maintainer Attention Maintainer attention needed! and removed Needs: Author Feedback Please give us the requested feedback! labels Feb 14, 2022
@JustinGrote JustinGrote added Needs: Repro Info 🤔 and removed Needs: Maintainer Attention Maintainer attention needed! labels Feb 14, 2022
@JustinGrote
Copy link
Collaborator

Have you tried it in a fresh session with no profile, or tried doing an isolated vscode install by downloading the zip, extracting it, and placing a "data" folder in the resulting extraction?

I can't reproduce this on a fresh installation, so we need to know what's different about your environment that is triggering this.

@itconsultingnc
Copy link
Author

Hi,
how can I launch a fresh session with no profile ?
I am downloading vs code zip file to try your second option.

@itconsultingnc
Copy link
Author

Hi,
I have downloaded Zip File, extract it, add a "data" directory, launch Code.exe from the extracted directory.
I have installed the powershell extension, try to create a simple nex ps1 file, but again, same error occur.
There is the \VSCode-win32-x64-1.64.2\data\extensions\ms-vscode.powershell-2021.12.0 directory after installing powershell extension.

@JustinGrote
Copy link
Collaborator

JustinGrote commented Feb 15, 2022

image
This path indicated you are running in Azure Pipelines?
https://github.com/YakDriver/azure-pipelines-environment-variables#build_repository_localpath

@andschwa maybe something in your build pipeline hardcoded something somewhere?

EDIT: Nevermind this is probably the symbol PDBs

Maybe a regression of #3297?

@itconsultingnc
Copy link
Author

I am not using Azure pipelines.
Just Using Azure Functions Extensions.

@JustinGrote
Copy link
Collaborator

JustinGrote commented Feb 15, 2022

@itconsultingnc have you tried on a different computer or a fresh user profile? Can you potentially enable the PSES diagnostic logs and get a capture?
https://github.com/PowerShell/vscode-powershell/blob/master/docs/troubleshooting.md#providing-information-about-your-environment

@itconsultingnc
Copy link
Author

Hi,
here are the 3 log file
EditorServices.log
StartEditorServices.log
vscode-powershell.log

Thank you

@JustinGrote
Copy link
Collaborator

@andschwa @SeeminglyScience maybe something to do with the input/output encoding?

== Console Details ==
 - Console input encoding: Europe de l'Ouest (DOS)
 - Console output encoding: Europe de l'Ouest (DOS)
 - PowerShell output encoding: US-ASCII

Only thing I can see as a possibility.

@itconsultingnc
Copy link
Author

Hi,
is there something else I have to check ?
I am still stuck with this problem and Can't use Visual studio code as an envireonnement for deveveloppement with powershell...
Azure function extension work fine, can publish to azure app function.

@JustinGrote
Copy link
Collaborator

@itconsultingnc The only thing I can see unusual is that it appears you are using a non-English computer, I don't know if you have the ability to change the language just to test that aspect of it.

@ghost
Copy link

ghost commented Feb 27, 2022

This issue was closed automatically as repro info was indicated as needed, but there has been no activity in over a week. Please feel free to reopen with any available information!

@ghost ghost closed this as completed Feb 27, 2022
@itconsultingnc
Copy link
Author

Hi,
changing language didn't solve the problem.

@itconsultingnc
Copy link
Author

Hi,

adding extrapaths worked , but this is the only powershell version working now ...

"powershell.powerShellAdditionalExePaths": [
{
"exePath": "C:\Program Files\PowerShell\7\pwsh.exe",
"versionName": "PSW7"
}
]

@andyleejordan andyleejordan reopened this Mar 7, 2022
@andyleejordan
Copy link
Member

Just Using Azure Functions Extensions.

What do you mean exactly by this?

@andyleejordan
Copy link
Member

Hi,

adding extrapaths worked , but this is the only powershell version working now ...

"powershell.powerShellAdditionalExePaths": [ { "exePath": "C:\Program Files\PowerShell\7\pwsh.exe", "versionName": "PSW7" } ]

This makes sense to be honest. Windows PowerShell 5.1 support is "best effort" as it's missing a lot of the improvements we rely on to make things stable. If the extension is working for you with the most recent version of PowerShell (e.g. pwsh / PowerShell 7), fantastic! Please use it 😄

@itconsultingnc
Copy link
Author

Just Using Azure Functions Extensions.

What do you mean exactly by this?

I mean I am not using Azure Pipeline, just Azure Function.
with a lot other extension ( Powershell,Git,etc...), but the other are not related to Azure.
I will get rid of PSW 5 so.
thank you for your attention

@ajbobo-nice
Copy link

I started seeing this same error about 2-3 days ago.
I have tried uninstalling and reinstalling the extension (PowerShell v2022.7.2) as well as disabling/uninstalling various other extensions.
Finally, I uninstalled VSCode, deleted my .vscode and /AppData/Roaming/Code directories. I then reinstalled VSCode, did NOT log into any of my accounts, and installed the PowerShell extension. The error is still happening.

I am using:
Windows 10 - version 21H1
VSCode - version 1.70.2 (system setup)
PowerShell Extension - v2022.7.2
PowerShell - version 5.1.19041.1682

@ghost
Copy link

ghost commented Aug 19, 2022

Thank you for your comment, but please note that this issue has been closed for over a week. For better visibility, consider opening a new issue with a link to this instead.

@andyleejordan
Copy link
Member

Hello @ajbobo-nice! The latest code is available in the PowerShell Preview for VS Code, and includes a myriad of fixes. Could you verify if this issue still reproduces using the preview extension? Please note that this preview is likely to include other bugs, and you should feel free to file new issues for those so we can work through them. Thanks again!

@ajbobo-nice
Copy link

@andschwa - Thank you for your quick response. To keep things clean, I just logged out of VSCode, uninstalled all of my extensions, then deleted the same folders as before. I installed PowerShell Preview in this (more or less) fresh environment and the error still appears when I start the PowerShell Extension.

@andyleejordan
Copy link
Member

Hm...does it work if you switch it to PowerShell 7? We unfortunately support PowerShell 5.1 as "best-effort," as it lacks so many of the APIs we require for a stable experience that just about anything can break it (for instance, it doesn't have Assembly Load Contexts which means any installed module or dependency can bring in a DLL that compromises compatibility).

@ajbobo-nice
Copy link

I installed PowerShell 7.2.6 and that works nicely. Thank you for your help!

@andyleejordan
Copy link
Member

Fantastic, glad we got you going again! PowerShell 7 should be a great experience.

@henrystaples
Copy link

I continue to have the issue and just installed PowerShell Preview (uninstalling PowerShell). I have PowerShell v7.2.5. I am running on an AWS Workspace, which is skinned for Win10, but is Win Server 2016 underneath.

image

@ghost
Copy link

ghost commented Sep 14, 2022

Thank you for your comment, but please note that this issue has been closed for over a week. For better visibility, consider opening a new issue with a link to this instead.

@andyleejordan
Copy link
Member

andyleejordan commented Oct 5, 2022

@henrystaples @itconsultingnc @ajbobo-nice Good news! We finally managed to figure out the root cause of (at least) the original posted problem in this issue. We'll have a new preview out hopefully this month with the fix (though we're dependent on a dependency to take our PR and get a new version of their own out, so it may be a bit). (Notably this only effects Windows PowerShell 5.1.)

@Aberlake
Copy link

I have just started having a similar issue. I've downgraded to older versions of VSCode but this doesn't fix this. Is this fix in 1.73.1 or is it still in preview?

@ghost
Copy link

ghost commented Nov 28, 2022

Thank you for your comment, but please note that this issue has been closed for over a week. For better visibility, consider opening a new issue with a link to this instead.

@andyleejordan
Copy link
Member

The fix is in an update to the PowerShell Extension not VS Code itself. Can you check what version of the extension you have installed?

@Aberlake
Copy link

Hi. I'm currently using v2022.11.0 and have tried the preview V2022.11.1 Both exhibit the same behaviour. Meantime I've just discovered current open issue #4278 (#4278), which is an exact match to my issue, so I'll follow from there. I should have checked the open items first - but this is only my second-ever comment on GitHub! :D

@andyleejordan
Copy link
Member

Thanks @Aberlake!

@andyleejordan
Copy link
Member

Hey @Aberlake can you please try the latest PowerShell Preview for VS Code and see if this is fixed?

@henrystaples
Copy link

henrystaples commented Nov 30, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash.
Projects
None yet
Development

No branches or pull requests

6 participants