PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.71k stars 491 forks source link

Mac OS X: $Error variable contains error: "Cannot find drive. A drive with the name 'C' does not exist." #694

Closed pcgeek86 closed 4 years ago

pcgeek86 commented 7 years ago

System Details

PS /Users/tsulli/OSCON> code -v
1.11.2
6eaebe3b9c70406d67c97779468c324a7a95db0e
PS /Users/tsulli/OSCON> $pseditor.EditorServicesVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
0      12     1      0

PS /Users/tsulli/OSCON> code --list-extensions --show-versions
Alexander.theme-sublime-oceanicnext@0.0.3
Nuuf.theme-hackershaze@1.3.1
PeterJausovec.vscode-docker@0.0.13
abusaidm.html-snippets@0.1.0
akamud.vscode-theme-onedark@1.3.2
aws-scripting-guy.cform@0.0.9
azemoh.one-monokai@0.2.4
christian-kohler.npm-intellisense@1.3.0
dlech.chmod@1.0.0
donjayamanne.python@0.6.3
ecmel.vscode-html-css@0.1.2
eg2.vscode-npm-script@0.1.9
fknop.vscode-npm@3.3.0
jakeboone02.mediawiki@2.1.0
jprestidge.theme-material-theme@1.0.1
ms-vscode.cpptools@0.10.5
ms-vscode.csharp@1.9.0
ms-vscode.PowerShell@0.12.2
searKing.preview-vscode@1.1.5
PS /Users/tsulli/OSCON> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.0.0-alpha
PSEdition                      Core
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   3.0.0.0
GitCommitId                    v6.0.0-alpha.18
CLRVersion
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

When launching a new VSCode session, the VSCode PowerShell host process has already thrown an exception in the $Error automatic variable, even when the user has not invoked any commands in the Integrated Terminal.

ErrorRecord                 : Cannot find drive. A drive with the name 'C' does not exist.
WasThrownFromThrowStatement : False
Message                     : Cannot find drive. A drive with the name 'C' does not exist.
Data                        : {}
InnerException              : System.Management.Automation.DriveNotFoundException: Cannot find drive. A drive with the name 'C' does not exist.
                                 at System.Management.Automation.SessionStateInternal.GetDrive(String name, Boolean automount)
                                 at System.Management.Automation.SessionStateInternal.AutomountBuiltInDrive(String name)
                                 at System.Management.Automation.SessionStateInternal.GetDrive(String name, Boolean automount)
                                 at System.Management.Automation.SessionStateInternal.GetDrive(String name)
                                 at System.Management.Automation.DriveManagementIntrinsics.Get(String driveName)
                                 at System.Management.Automation.LocationGlobber.GetDriveRootRelativePathFromPSPath(String path, CmdletProviderContext context, Boolean
                              escapeCurrentLocation, PSDriveInfo& workingDriveForPath, CmdletProvider& providerInstance)
                                 at System.Management.Automation.LocationGlobber.GetProviderPath(String path, CmdletProviderContext context, Boolean isTrusted,
                              ProviderInfo& provider, PSDriveInfo& drive)
                                 at System.Management.Automation.LocationGlobber.GetProviderPath(String path, CmdletProviderContext context, ProviderInfo& provider,
                              PSDriveInfo& drive)
                                 at System.Management.Automation.LocationGlobber.GetGlobbedProviderPathsFromMonadPath(String path, Boolean allowNonexistingPaths,
                              CmdletProviderContext context, ProviderInfo& provider, CmdletProvider& providerInstance)
                                 at System.Management.Automation.LocationGlobber.GetGlobbedProviderPathsFromMonadPath(String path, Boolean allowNonexistingPaths,
                              ProviderInfo& provider, CmdletProvider& providerInstance)
                                 at System.Management.Automation.PathIntrinsics.GetResolvedProviderPathFromPSPath(String path, ProviderInfo& provider)
                                 at Microsoft.PowerShell.Commands.ModuleCmdletBase.ResolveRootedFilePath(String filePath, ExecutionContext context)
                                 at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName(ImportModuleOptions importModuleOptions, String name)
                                 at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()
                                 at System.Management.Automation.Cmdlet.DoProcessRecord()
                                 at System.Management.Automation.CommandProcessor.ProcessRecord()
TargetSite                  : System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject] Invoke(System.Collections.IEnumerable)
StackTrace                  :    at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)
                                 at System.Management.Automation.Runspaces.Pipeline.Invoke()
                                 at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
                                 at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
                                 at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output,
                              PSInvocationSettings settings)
                                 at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output,
                              PSInvocationSettings settings)
                                 at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable input, PSDataCollection`1 output, PSInvocationSettings
                              settings)
                                 at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
                                 at System.Management.Automation.PowerShell.Invoke()
                                 at Microsoft.PowerShell.EditorServices.Session.Capabilities.DscBreakpointCapability.CheckForCapability(RunspaceDetails runspaceDetails,
                              PowerShellContext powerShellContext)
HelpLink                    :
Source                      : System.Management.Automation
HResult                     : -2146233088
Starting PowerShell...

PS /Users/tsulli/OSCON> $error
Cannot find drive. A drive with the name 'C' does not exist.
PS /Users/tsulli/OSCON> $Error.count
1
PS /Users/tsulli/OSCON> $Error | fl *
Cannot find drive. A drive with the name 'C' does not exist.
PS /Users/tsulli/OSCON> $Error | gm

   TypeName: System.Management.Automation.CmdletInvocationException

Name                        MemberType Definition
----                        ---------- ----------
Equals                      Method     bool Equals(System.Object obj)
GetBaseException            Method     System.Exception GetBaseException()
GetHashCode                 Method     int GetHashCode()
GetObjectData               Method     void GetObjectData(Microsoft.PowerShell.CoreClr.Stubs.SerializationInfo info, System.Runtime.Serialization.StreamingContext cont...
GetType                     Method     type GetType()
ToString                    Method     string ToString()
Data                        Property   System.Collections.IDictionary Data {get;}
ErrorRecord                 Property   System.Management.Automation.ErrorRecord ErrorRecord {get;}
HelpLink                    Property   string HelpLink {get;set;}
HResult                     Property   int HResult {get;set;}
InnerException              Property   System.Exception InnerException {get;}
Message                     Property   string Message {get;}
Source                      Property   string Source {get;set;}
StackTrace                  Property   string StackTrace {get;}
TargetSite                  Property   System.Reflection.MethodBase TargetSite {get;}
WasThrownFromThrowStatement Property   bool WasThrownFromThrowStatement {get;set;}

Cheers, Trevor Sullivan

bgelens commented 7 years ago

Maybe this is relatable to an issue I had with PSv6 remoting https://github.com/PowerShell/PowerShell/issues/3553

pcgeek86 commented 7 years ago

Looks very similar, yes.

daviwil commented 7 years ago

Thanks guys! This is strange, I'll take a look. I wonder if I'm causing it somehow.

TylerLeonhardt commented 4 years ago

Just gave this a try and it's not reproing. It's probably that old PowerShell/PowerShell issue. I'm going to close this but if you still see it let me know!