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

Start-EditorServices.ps1 - [System.Net.Dns]::GetHostEntryAsync returns null on macOS

Open jackmusick opened this issue 9 years ago • 5 comments

Logs.zip

System Details

  • Operating system name and version: macOS 10.12.3
  • VS Code version: 1.8.1
  • PowerShell extension version: 0.9.0
  • Output from $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.15
CLRVersion
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Evaluate $PSVersionTable in PowerShell and paste the output here

Issue Description

Upon starting Visual Studio Code with a PowerShell file, I get 'PowerShell could not be started, click 'Show Logs' for more details. When looking at the logs, I get this:

ERROR: Cannot index into a null array.

PowerShell could not be started, click 'Show Logs' for more details.
ERROR: At /Users/jack/.vscode/extensions/ms-vscode.PowerShell-0.9.0/scripts/Start-Edit
orServices.ps1:108 char:13
+             $ipAddress = [System.Net.Dns]::GetHostEntryAsync("localho ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

If I try to debug a script anyways, it eventually times out and tells me Timed out waiting for the PowerShell extension to start. The DebugAdapter.log file gives me:

Waiting for session file, tries remaining: 30... and of course, times out.

It appears it's having problems with this command:

$ipAddress = [System.Net.Dns]::GetHostEntryAsync("localhost").Result.AddressList[0];

When I run that from the PowerShell prompt, I receive the same error as above (Cannot index into a null array).

I've also tried this on my MacBook Pro running the same version of PowerShell, VS Code, the PowerShell extension and macOS. My experience is that the logging looks the exact same and that last command gives me the exact same error. For some reason, the extension doesn't care so much in that instance.

Attached Logs

Follow the instructions in the README about capturing and sending logs.

Logs.zip

jackmusick avatar Feb 02 '17 15:02 jackmusick

That's weird, I've never seen that particular call fail before. I haven't tried the extension with alpha15 on macOS yet, maybe something changed that I wasn't aware of. I'll look into it.

daviwil avatar Feb 02 '17 15:02 daviwil

Thanks for the detailed notes, by the way!

daviwil avatar Feb 02 '17 15:02 daviwil

Not a problem! Your issue template helped a lot. If you know of a complete way to remove all things Visual Studio Code and PowerShell from macOS, I could try that and give you an update. I've tried simply removing the app and PowerShell in /usr/local/microsoft/powershell, but that didn't seem to help.

jackmusick avatar Feb 02 '17 22:02 jackmusick

This might have been an issue with my system. For some reason, I didn't have localhost pointing to 127.0.0.1 in my hosts file. After adding that back, it seems to work just fine. I wouldn't have been able to find that without your excellent logging so kudos!

jackmusick avatar Feb 02 '17 23:02 jackmusick

Thanks Jack! Glad you were able to figure it out.

daviwil avatar Feb 09 '17 23:02 daviwil